Added ability for Radio Buttons to span Columns
This commit is contained in:
parent
a7baf94764
commit
59988dd430
|
@ -899,7 +899,7 @@ class Radio(Element):
|
||||||
tooltip=tooltip, visible=visible)
|
tooltip=tooltip, visible=visible)
|
||||||
|
|
||||||
def Update(self, value=None, disabled=None, visible=None):
|
def Update(self, value=None, disabled=None, visible=None):
|
||||||
location = EncodeRadioRowCol(self.Position[0], self.Position[1])
|
location = EncodeRadioRowCol(self.ParentForm.ContainerElemementNumber, self.Position[0], self.Position[1])
|
||||||
if value is not None:
|
if value is not None:
|
||||||
try:
|
try:
|
||||||
self.TKIntVar.set(location)
|
self.TKIntVar.set(location)
|
||||||
|
@ -1884,7 +1884,10 @@ class Image(Element):
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
width, height = size[0] or image.width(), size[1] or image.height()
|
width, height = size[0] or image.width(), size[1] or image.height()
|
||||||
self.tktext_label.configure(image=image, width=width, height=height)
|
try: # sometimes crashes if user closed with X
|
||||||
|
self.tktext_label.configure(image=image, width=width, height=height)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.tktext_label.image = image
|
self.tktext_label.image = image
|
||||||
if visible is False:
|
if visible is False:
|
||||||
self.tktext_label.pack_forget()
|
self.tktext_label.pack_forget()
|
||||||
|
@ -2308,6 +2311,8 @@ class Frame(Element):
|
||||||
self.BorderWidth = border_width
|
self.BorderWidth = border_width
|
||||||
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
||||||
self.RightClickMenu = right_click_menu
|
self.RightClickMenu = right_click_menu
|
||||||
|
self.ContainerElemementNumber = Window.GetAContainerNumber()
|
||||||
|
|
||||||
self.Layout(layout)
|
self.Layout(layout)
|
||||||
|
|
||||||
super().__init__(ELEM_TYPE_FRAME, background_color=background_color, text_color=title_color, size=size,
|
super().__init__(ELEM_TYPE_FRAME, background_color=background_color, text_color=title_color, size=size,
|
||||||
|
@ -2412,6 +2417,7 @@ class Tab(Element):
|
||||||
self.TabID = None
|
self.TabID = None
|
||||||
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
||||||
self.RightClickMenu = right_click_menu
|
self.RightClickMenu = right_click_menu
|
||||||
|
self.ContainerElemementNumber = Window.GetAContainerNumber()
|
||||||
|
|
||||||
self.Layout(layout)
|
self.Layout(layout)
|
||||||
|
|
||||||
|
@ -2575,7 +2581,7 @@ class Slider(Element):
|
||||||
:param tooltip:
|
:param tooltip:
|
||||||
:param visible:
|
:param visible:
|
||||||
'''
|
'''
|
||||||
self.TKScale = None
|
self.TKScale = None # type: tk.Scale
|
||||||
self.Range = (1, 10) if range == (None, None) else range
|
self.Range = (1, 10) if range == (None, None) else range
|
||||||
self.DefaultValue = self.Range[0] if default_value is None else default_value
|
self.DefaultValue = self.Range[0] if default_value is None else default_value
|
||||||
self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION
|
self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION
|
||||||
|
@ -2757,7 +2763,7 @@ class Column(Element):
|
||||||
self.VerticalScrollOnly = vertical_scroll_only
|
self.VerticalScrollOnly = vertical_scroll_only
|
||||||
self.RightClickMenu = right_click_menu
|
self.RightClickMenu = right_click_menu
|
||||||
bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
||||||
|
self.ContainerElemementNumber = Window.GetAContainerNumber()
|
||||||
|
|
||||||
self.Layout(layout)
|
self.Layout(layout)
|
||||||
|
|
||||||
|
@ -3477,7 +3483,7 @@ class Window:
|
||||||
user_defined_icon = None
|
user_defined_icon = None
|
||||||
hidden_master_root = None
|
hidden_master_root = None
|
||||||
animated_popup_dict = {}
|
animated_popup_dict = {}
|
||||||
|
container_element_counter = 0 # used to get a number of Container Elements (Frame, Column, Tab)
|
||||||
|
|
||||||
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||||
auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None), element_padding=None, margins=(None, None), button_color=None, font=None,
|
auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None), element_padding=None, margins=(None, None), button_color=None, font=None,
|
||||||
|
@ -3570,6 +3576,13 @@ class Window:
|
||||||
self.ElementPadding = element_padding or DEFAULT_ELEMENT_PADDING
|
self.ElementPadding = element_padding or DEFAULT_ELEMENT_PADDING
|
||||||
self.RightClickMenu = right_click_menu
|
self.RightClickMenu = right_click_menu
|
||||||
self.Margins = margins if margins != (None, None) else DEFAULT_MARGINS
|
self.Margins = margins if margins != (None, None) else DEFAULT_MARGINS
|
||||||
|
self.ContainerElemementNumber = Window.GetAContainerNumber()
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def GetAContainerNumber(cls):
|
||||||
|
cls.container_element_counter += 1
|
||||||
|
return cls.container_element_counter
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def IncrementOpenCount(self):
|
def IncrementOpenCount(self):
|
||||||
|
@ -4337,13 +4350,14 @@ def InitializeResults(form):
|
||||||
# ===== Radio Button RadVar encoding and decoding =====#
|
# ===== Radio Button RadVar encoding and decoding =====#
|
||||||
# ===== The value is simply the row * 1000 + col =====#
|
# ===== The value is simply the row * 1000 + col =====#
|
||||||
def DecodeRadioRowCol(RadValue):
|
def DecodeRadioRowCol(RadValue):
|
||||||
|
container = RadValue // 100000
|
||||||
row = RadValue // 1000
|
row = RadValue // 1000
|
||||||
col = RadValue % 1000
|
col = RadValue % 1000
|
||||||
return row, col
|
return container, row, col
|
||||||
|
|
||||||
|
|
||||||
def EncodeRadioRowCol(row, col):
|
def EncodeRadioRowCol(container, row, col):
|
||||||
RadValue = row * 1000 + col
|
RadValue = container*100000 + row * 1000 + col
|
||||||
return RadValue
|
return RadValue
|
||||||
|
|
||||||
|
|
||||||
|
@ -4446,7 +4460,7 @@ def BuildResultsForSubform(form, initialize_only, top_level_form):
|
||||||
value = (value != 0)
|
value = (value != 0)
|
||||||
elif element.Type == ELEM_TYPE_INPUT_RADIO:
|
elif element.Type == ELEM_TYPE_INPUT_RADIO:
|
||||||
RadVar = element.TKIntVar.get()
|
RadVar = element.TKIntVar.get()
|
||||||
this_rowcol = EncodeRadioRowCol(row_num, col_num)
|
this_rowcol = EncodeRadioRowCol(element.ParentForm.ContainerElemementNumber, row_num, col_num)
|
||||||
value = RadVar == this_rowcol
|
value = RadVar == this_rowcol
|
||||||
elif element.Type == ELEM_TYPE_BUTTON:
|
elif element.Type == ELEM_TYPE_BUTTON:
|
||||||
if top_level_form.LastButtonClicked == element.ButtonText:
|
if top_level_form.LastButtonClicked == element.ButtonText:
|
||||||
|
@ -4942,7 +4956,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
wraplen = tktext_label.winfo_reqwidth() + 40 # width of widget in Pixels
|
wraplen = tktext_label.winfo_reqwidth() + 40 # width of widget in Pixels
|
||||||
if not auto_size_text and height == 1:
|
if not auto_size_text and height == 1:
|
||||||
wraplen = 0
|
wraplen = 0
|
||||||
# print("wraplen, width, height", wraplen, width, height)
|
|
||||||
tktext_label.configure(anchor=anchor, wraplen=wraplen) # set wrap to width of widget
|
tktext_label.configure(anchor=anchor, wraplen=wraplen) # set wrap to width of widget
|
||||||
if element.Relief is not None:
|
if element.Relief is not None:
|
||||||
tktext_label.configure(relief=element.Relief)
|
tktext_label.configure(relief=element.Relief)
|
||||||
|
@ -5377,7 +5390,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
default_value = element.InitialState
|
default_value = element.InitialState
|
||||||
ID = element.GroupID
|
ID = element.GroupID
|
||||||
# see if ID has already been placed
|
# see if ID has already been placed
|
||||||
value = EncodeRadioRowCol(row_num, col_num) # value to set intvar to if this radio is selected
|
value = EncodeRadioRowCol(form.ContainerElemementNumber, row_num, col_num) # value to set intvar to if this radio is selected
|
||||||
if ID in toplevel_form.RadioDict:
|
if ID in toplevel_form.RadioDict:
|
||||||
RadVar = toplevel_form.RadioDict[ID]
|
RadVar = toplevel_form.RadioDict[ID]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue