Merge pull request #3742 from PySimpleGUI/Dev-latest

Merry Christmas to the invisible wishers - element.visible added to a…
This commit is contained in:
PySimpleGUI 2020-12-25 11:34:19 -05:00 committed by GitHub
commit 3e990180e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 87 additions and 29 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.32.1.13 Unreleased\nRemoved faking timeout message as it can happen when autoclose used, CLOSE_ATTEMPED_EVENT, button_color can have a None parameter, fill_color added to draw_arc, 16x16 icon, Titlebar element, set_option gets custom titlebar option, tons of sh*t for custom titlebars, if running on Trinket then use custom titlebars by default, smarter titlebar handling..auto remove, added key to titlebar image, renamed InputText to Input, massive nngogol Union docstring fix!, finally custom titlebar minimize works on Linux and can also be pinned and made invisible" version = __version__ = "4.32.1.14 Unreleased\nRemoved faking timeout message as it can happen when autoclose used, CLOSE_ATTEMPED_EVENT, button_color can have a None parameter, fill_color added to draw_arc, 16x16 icon, Titlebar element, set_option gets custom titlebar option, tons of sh*t for custom titlebars, if running on Trinket then use custom titlebars by default, smarter titlebar handling..auto remove, added key to titlebar image, renamed InputText to Input, massive nngogol Union docstring fix!, finally custom titlebar minimize works on Linux and can also be pinned and made invisible, .visible added to all elements"
__version__ = version.split()[0] # For PEP 396 and PEP 345 __version__ = version.split()[0] # For PEP 396 and PEP 345
@ -752,7 +752,7 @@ class Element():
self.Key = key # dictionary key for return values self.Key = key # dictionary key for return values
self.Tooltip = tooltip self.Tooltip = tooltip
self.TooltipObject = None self.TooltipObject = None
self.Visible = visible self.visible = visible
self.TKRightClickMenu = None self.TKRightClickMenu = None
self.Widget = None # Set when creating window. Has the main tkinter widget for element self.Widget = None # Set when creating window. Has the main tkinter widget for element
self.Tearoff = False # needed because of right click menu code self.Tearoff = False # needed because of right click menu code
@ -1355,6 +1355,9 @@ class Input(Element):
# print(f'Other widgets on row = {self.ParentRowFrame.pack_slaves()}') # print(f'Other widgets on row = {self.ParentRowFrame.pack_slaves()}')
self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1])
# self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1], in_=self.ParentRowFrame) # self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1], in_=self.ParentRowFrame)
if visible is not None:
self.visible = visible
def Get(self): def Get(self):
""" """
@ -1506,6 +1509,8 @@ class Combo(Element):
self.TKCombo.pack_forget() self.TKCombo.pack_forget()
elif visible is True: elif visible is True:
self.TKCombo.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKCombo.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
def Get(self): def Get(self):
""" """
@ -1630,6 +1635,8 @@ class OptionMenu(Element):
self.TKOptionMenu.pack_forget() self.TKOptionMenu.pack_forget()
elif visible is True: elif visible is True:
self.TKOptionMenu.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKOptionMenu.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
set_focus = Element.SetFocus set_focus = Element.SetFocus
set_tooltip = Element.SetTooltip set_tooltip = Element.SetTooltip
@ -1781,6 +1788,8 @@ class Listbox(Element):
self.TKListbox.config(selectmode=select_mode) self.TKListbox.config(selectmode=select_mode)
except: except:
print('Listbox.update error trying to change mode to: ', select_mode) print('Listbox.update error trying to change mode to: ', select_mode)
if visible is not None:
self.visible = visible
def SetValue(self, values): def SetValue(self, values):
""" """
@ -1984,6 +1993,8 @@ class Radio(Element):
self.TKRadio.pack_forget() self.TKRadio.pack_forget()
elif visible is True: elif visible is True:
self.TKRadio.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKRadio.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
def ResetGroup(self): def ResetGroup(self):
""" """
@ -2157,6 +2168,8 @@ class Checkbox(Element):
self.TKCheckbutton.pack_forget() self.TKCheckbutton.pack_forget()
elif visible is True: elif visible is True:
self.TKCheckbutton.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKCheckbutton.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
get = Get get = Get
set_focus = Element.SetFocus set_focus = Element.SetFocus
@ -2286,6 +2299,8 @@ class Spin(Element):
self.TKSpinBox.pack_forget() self.TKSpinBox.pack_forget()
elif visible is True: elif visible is True:
self.TKSpinBox.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKSpinBox.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
def _SpinChangedHandler(self, event): def _SpinChangedHandler(self, event):
""" """
@ -2531,6 +2546,8 @@ class Multiline(Element):
self.ParentForm.refresh() self.ParentForm.refresh()
except: except:
pass pass
if visible is not None:
self.visible = visible
def Get(self): def Get(self):
@ -2739,6 +2756,8 @@ class Text(Element):
self.TKText.pack_forget() self.TKText.pack_forget()
elif visible is True: elif visible is True:
self.TKText.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKText.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
def Get(self): def Get(self):
""" """
@ -2861,6 +2880,8 @@ class StatusBar(Element):
self.TKText.pack_forget() self.TKText.pack_forget()
elif visible is True: elif visible is True:
self.TKText.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKText.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
set_focus = Element.SetFocus set_focus = Element.SetFocus
set_tooltip = Element.SetTooltip set_tooltip = Element.SetTooltip
@ -3149,6 +3170,8 @@ class Output(Element):
self._TKOut.frame.pack_forget() self._TKOut.frame.pack_forget()
elif visible is True: elif visible is True:
self._TKOut.frame.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self._TKOut.frame.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
def Get(self): def Get(self):
""" """
@ -3697,6 +3720,10 @@ class Button(Element):
self.DisabledButtonColor = (disabled_button_color[0] if disabled_button_color[0] is not None else self.DisabledButtonColor[0], self.DisabledButtonColor = (disabled_button_color[0] if disabled_button_color[0] is not None else self.DisabledButtonColor[0],
disabled_button_color[1] if disabled_button_color[1] is not None else self.DisabledButtonColor[1]) disabled_button_color[1] if disabled_button_color[1] is not None else self.DisabledButtonColor[1])
if visible is not None:
self.visible = visible
def GetText(self): def GetText(self):
""" """
Returns the current text shown on a button Returns the current text shown on a button
@ -3853,6 +3880,8 @@ class ButtonMenu(Element):
self.TKButtonMenu.pack_forget() self.TKButtonMenu.pack_forget()
elif visible is True: elif visible is True:
self.TKButtonMenu.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKButtonMenu.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
def Click(self): def Click(self):
""" """
@ -3984,6 +4013,8 @@ class ProgressBar(Element):
self.TKProgressBar.TKProgressBarForReal.pack_forget() self.TKProgressBar.TKProgressBarForReal.pack_forget()
elif visible is True: elif visible is True:
self.TKProgressBar.TKProgressBarForReal.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKProgressBar.TKProgressBarForReal.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
self.TKProgressBar.Update(current_count, max=max) self.TKProgressBar.Update(current_count, max=max)
try: try:
@ -4107,6 +4138,8 @@ class Image(Element):
# if everything is set to None, then delete the image # if everything is set to None, then delete the image
if filename is None and image is None and visible is None and size == (None, None): if filename is None and image is None and visible is None and size == (None, None):
self.tktext_label.image = None self.tktext_label.image = None
if visible is not None:
self.visible = visible
def UpdateAnimation(self, source, time_between_frames=0): def UpdateAnimation(self, source, time_between_frames=0):
@ -4763,6 +4796,8 @@ class Graph(Element):
self._TKCanvas2.pack_forget() self._TKCanvas2.pack_forget()
elif visible is True: elif visible is True:
self._TKCanvas2.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self._TKCanvas2.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
def Move(self, x_direction, y_direction): def Move(self, x_direction, y_direction):
""" """
@ -5175,6 +5210,8 @@ class Frame(Element):
self.TKFrame.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKFrame.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if value is not None: if value is not None:
self.TKFrame.config(text=str(value)) self.TKFrame.config(text=str(value))
if visible is not None:
self.visible = visible
add_row = AddRow add_row = AddRow
layout = Layout layout = Layout
@ -5411,6 +5448,9 @@ class Tab(Element):
state = 'disabled' state = 'disabled'
if visible is False: if visible is False:
state = 'hidden' state = 'hidden'
if visible is not None:
self.visible = visible
self.ParentNotebook.tab(self.TabID, state=state) self.ParentNotebook.tab(self.TabID, state=state)
if title is not None: if title is not None:
@ -5778,6 +5818,8 @@ class Slider(Element):
self.TKScale.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKScale.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if range != (None, None): if range != (None, None):
self.TKScale.config(from_=range[0], to_=range[1]) self.TKScale.config(from_=range[0], to_=range[1])
if visible is not None:
self.visible = visible
def _SliderChangedHandler(self, event): def _SliderChangedHandler(self, event):
""" """
@ -6132,6 +6174,8 @@ class Column(Element):
self.TKColFrame.pack(padx=self.pad_used[0], pady=self.pad_used[1], fill=expand) self.TKColFrame.pack(padx=self.pad_used[0], pady=self.pad_used[1], fill=expand)
if self.ParentPanedWindow: if self.ParentPanedWindow:
self.ParentPanedWindow.add(self.TKColFrame) self.ParentPanedWindow.add(self.TKColFrame)
if visible is not None:
self.visible = visible
def contents_changed(self): def contents_changed(self):
""" """
@ -6228,6 +6272,8 @@ class Pane(Element):
self.PanedWindow.pack_forget() self.PanedWindow.pack_forget()
elif visible is True: elif visible is True:
self.PanedWindow.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.PanedWindow.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
set_focus = Element.SetFocus set_focus = Element.SetFocus
set_tooltip = Element.SetTooltip set_tooltip = Element.SetTooltip
@ -6577,6 +6623,8 @@ class Menu(Element):
self.ParentForm.TKroot.configure(menu=[]) # this will cause the menubar to disappear self.ParentForm.TKroot.configure(menu=[]) # this will cause the menubar to disappear
elif self.TKMenu is not None: elif self.TKMenu is not None:
self.ParentForm.TKroot.configure(menu=self.TKMenu) self.ParentForm.TKroot.configure(menu=self.TKMenu)
if visible is not None:
self.visible = visible
set_focus = Element.SetFocus set_focus = Element.SetFocus
set_tooltip = Element.SetTooltip set_tooltip = Element.SetTooltip
@ -6791,6 +6839,8 @@ class Table(Element):
self.TKTreeview.tag_configure(row_def[0], background=row_def[1]) self.TKTreeview.tag_configure(row_def[0], background=row_def[1])
else: else:
self.TKTreeview.tag_configure(row_def[0], background=row_def[2], foreground=row_def[1]) self.TKTreeview.tag_configure(row_def[0], background=row_def[2], foreground=row_def[1])
if visible is not None:
self.visible = visible
def _treeview_selected(self, event): def _treeview_selected(self, event):
""" """
@ -7089,6 +7139,9 @@ class Tree(Element):
self.TKTreeview.pack_forget() self.TKTreeview.pack_forget()
elif visible is True: elif visible is True:
self.TKTreeview.pack(padx=self.pad_used[0], pady=self.pad_used[1]) self.TKTreeview.pack(padx=self.pad_used[0], pady=self.pad_used[1])
if visible is not None:
self.visible = visible
return self return self
set_focus = Element.SetFocus set_focus = Element.SetFocus
@ -9803,7 +9856,7 @@ def vbottom(elem_or_row):
def Titlebar(title='',icon=None, text_color=None, background_color=None, font=None, key=None): def Titlebar(title='',icon=None, text_color=None, background_color=None, font=None, key=None, k=None):
""" """
A custom titlebar that replaces the OS provided titlebar, thus giving you control A custom titlebar that replaces the OS provided titlebar, thus giving you control
the is not possible using the OS provided titlebar such as the color. the is not possible using the OS provided titlebar such as the color.
@ -9832,11 +9885,16 @@ def Titlebar(title='',icon=None, text_color=None, background_color=None, font=No
:param font: Font to be used for the text and the symbols :param font: Font to be used for the text and the symbols
:type font: str :type font: str
:return: A list of elements (i.e. a "row" for a layout) :return: A list of elements (i.e. a "row" for a layout)
:param key: Identifies an Element. Should be UNIQUE to this window.
:type key: str | int | tuple | object
:param k: Exactly the same as key. Choose one of them to use
:type k: str | int | tuple | object
:rtype: List[Element] :rtype: List[Element]
""" """
bc = background_color or theme_button_color()[1] bc = background_color or theme_button_color()[1]
tc = text_color or theme_button_color()[0] tc = text_color or theme_button_color()[0]
font = font or ('Helvetica', 12) font = font or ('Helvetica', 12)
key = k or key
if isinstance(icon, bytes): if isinstance(icon, bytes):
icon_and_text_portion = [Image(data=icon, background_color=bc, key=TITLEBAR_IMAGE_KEY)] icon_and_text_portion = [Image(data=icon, background_color=bc, key=TITLEBAR_IMAGE_KEY)]
@ -11675,7 +11733,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKColFrame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill) element.TKColFrame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill)
# element.TKColFrame.pack(side=side, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') # element.TKColFrame.pack(side=side, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both')
if element.Visible is False: if element.visible is False:
element.TKColFrame.pack_forget() element.TKColFrame.pack_forget()
# element.TKColFrame = element.TKColFrame # element.TKColFrame = element.TKColFrame
# if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: # if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None:
@ -11708,7 +11766,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
pane.Widget = pane.TKColFrame = tk.Frame(element.PanedWindow) pane.Widget = pane.TKColFrame = tk.Frame(element.PanedWindow)
pane.ParentPanedWindow = element.PanedWindow pane.ParentPanedWindow = element.PanedWindow
PackFormIntoFrame(pane, pane.TKColFrame, toplevel_form) PackFormIntoFrame(pane, pane.TKColFrame, toplevel_form)
if pane.Visible: if pane.visible:
element.PanedWindow.add(pane.TKColFrame) element.PanedWindow.add(pane.TKColFrame)
if pane.BackgroundColor != COLOR_SYSTEM_DEFAULT and pane.BackgroundColor is not None: if pane.BackgroundColor != COLOR_SYSTEM_DEFAULT and pane.BackgroundColor is not None:
pane.TKColFrame.configure(background=pane.BackgroundColor, pane.TKColFrame.configure(background=pane.BackgroundColor,
@ -11716,7 +11774,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
highlightcolor=pane.BackgroundColor) highlightcolor=pane.BackgroundColor)
element.PanedWindow.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') element.PanedWindow.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both')
if element.Visible is False: if element.visible is False:
element.PanedWindow.pack_forget() element.PanedWindow.pack_forget()
# ------------------------- TEXT placement element ------------------------- # # ------------------------- TEXT placement element ------------------------- #
elif element_type == ELEM_TYPE_TEXT: elif element_type == ELEM_TYPE_TEXT:
@ -11766,7 +11824,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None:
tktext_label.configure(fg=element.TextColor) tktext_label.configure(fg=element.TextColor)
tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
tktext_label.pack_forget() tktext_label.pack_forget()
element.TKText = tktext_label element.TKText = tktext_label
if element.ClickSubmits: if element.ClickSubmits:
@ -11845,7 +11903,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if width != 0: if width != 0:
tkbutton.configure(wraplength=wraplen + 10) # set wrap to width of widget tkbutton.configure(wraplength=wraplen + 10) # set wrap to width of widget
tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
tkbutton.pack_forget() tkbutton.pack_forget()
if element.BindReturnKey: if element.BindReturnKey:
element.TKButton.bind('<Return>', element._ReturnKeyHandler) element.TKButton.bind('<Return>', element._ReturnKeyHandler)
@ -11957,7 +12015,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKButton = tkbutton # not used yet but save the TK button in case element.TKButton = tkbutton # not used yet but save the TK button in case
tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
tkbutton.pack_forget() tkbutton.pack_forget()
if element.BindReturnKey: if element.BindReturnKey:
element.TKButton.bind('<Return>', element._ReturnKeyHandler) element.TKButton.bind('<Return>', element._ReturnKeyHandler)
@ -12050,7 +12108,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
tkbutton.configure(menu=top_menu) tkbutton.configure(menu=top_menu)
element.TKMenu = top_menu element.TKMenu = top_menu
if element.Visible is False: if element.visible is False:
tkbutton.pack_forget() tkbutton.pack_forget()
if element.Disabled == True: if element.Disabled == True:
element.TKButton['state'] = 'disabled' element.TKButton['state'] = 'disabled'
@ -12092,7 +12150,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# element.pack_keywords = {'side':tk.LEFT, 'padx':elementpad[0], 'pady':elementpad[1], 'expand':False, 'fill':tk.NONE } # element.pack_keywords = {'side':tk.LEFT, 'padx':elementpad[0], 'pady':elementpad[1], 'expand':False, 'fill':tk.NONE }
# element.TKEntry.pack(**element.pack_keywords) # element.TKEntry.pack(**element.pack_keywords)
element.TKEntry.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=False, fill=tk.NONE) element.TKEntry.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=False, fill=tk.NONE)
if element.Visible is False: if element.visible is False:
element.TKEntry.pack_forget() element.TKEntry.pack_forget()
if element.Focus is True or (toplevel_form.UseDefaultFocus and not toplevel_form.FocusSet): if element.Focus is True or (toplevel_form.UseDefaultFocus and not toplevel_form.FocusSet):
toplevel_form.FocusSet = True toplevel_form.FocusSet = True
@ -12187,7 +12245,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKCombo['values'] = element.Values element.TKCombo['values'] = element.Values
element.TKCombo.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKCombo.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.TKCombo.pack_forget() element.TKCombo.pack_forget()
if element.DefaultValue is not None: if element.DefaultValue is not None:
element.TKCombo.set(element.DefaultValue) element.TKCombo.set(element.DefaultValue)
@ -12224,7 +12282,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None:
element.TKOptionMenu.configure(fg=element.TextColor) element.TKOptionMenu.configure(fg=element.TextColor)
element.TKOptionMenu.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKOptionMenu.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.TKOptionMenu.pack_forget() element.TKOptionMenu.pack_forget()
if element.Disabled == True: if element.Disabled == True:
element.TKOptionMenu['state'] = 'disabled' element.TKOptionMenu['state'] = 'disabled'
@ -12265,7 +12323,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKListbox.bind("<Leave>", lambda event, em=element: testMouseUnhook(em)) element.TKListbox.bind("<Leave>", lambda event, em=element: testMouseUnhook(em))
listbox_frame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) listbox_frame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
element.TKListbox.pack(side=tk.LEFT) element.TKListbox.pack(side=tk.LEFT)
if element.Visible is False: if element.visible is False:
listbox_frame.pack_forget() listbox_frame.pack_forget()
element.vsb.pack_forget() element.vsb.pack_forget()
if element.BindReturnKey: if element.BindReturnKey:
@ -12307,7 +12365,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# if DEFAULT_SCROLLBAR_COLOR not in (None, COLOR_SYSTEM_DEFAULT): # only works on Linux so not including it # if DEFAULT_SCROLLBAR_COLOR not in (None, COLOR_SYSTEM_DEFAULT): # only works on Linux so not including it
# element.TKText.vbar.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) # element.TKText.vbar.config(troughcolor=DEFAULT_SCROLLBAR_COLOR)
element.TKText.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKText.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.TKText.pack_forget() element.TKText.pack_forget()
else: else:
# Chr0nic # Chr0nic
@ -12367,7 +12425,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKCheckbutton.config(highlightcolor=element.TextColor) element.TKCheckbutton.config(highlightcolor=element.TextColor)
element.TKCheckbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKCheckbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.TKCheckbutton.pack_forget() element.TKCheckbutton.pack_forget()
if element.Tooltip is not None: if element.Tooltip is not None:
element.TooltipObject = ToolTip(element.TKCheckbutton, text=element.Tooltip, element.TooltipObject = ToolTip(element.TKCheckbutton, text=element.Tooltip,
@ -12391,7 +12449,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
border_width=element.BorderWidth, relief=element.Relief, border_width=element.BorderWidth, relief=element.Relief,
style=toplevel_form.TtkTheme, key=element.Key) style=toplevel_form.TtkTheme, key=element.Key)
element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.TKProgressBar.TKProgressBarForReal.pack_forget() element.TKProgressBar.TKProgressBarForReal.pack_forget()
element.Widget = element.TKProgressBar.TKProgressBarForReal element.Widget = element.TKProgressBar.TKProgressBarForReal
# ------------------------- RADIO placement element ------------------------- # # ------------------------- RADIO placement element ------------------------- #
@ -12439,7 +12497,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.Disabled: if element.Disabled:
element.TKRadio['state'] = 'disabled' element.TKRadio['state'] = 'disabled'
element.TKRadio.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKRadio.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.TKRadio.pack_forget() element.TKRadio.pack_forget()
if element.Tooltip is not None: if element.Tooltip is not None:
element.TooltipObject = ToolTip(element.TKRadio, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME) element.TooltipObject = ToolTip(element.TKRadio, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
@ -12460,7 +12518,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKSpinBox.configure(buttonbackground=element.BackgroundColor) element.TKSpinBox.configure(buttonbackground=element.BackgroundColor)
element.Widget.config(highlightthickness=0) element.Widget.config(highlightthickness=0)
element.TKSpinBox.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKSpinBox.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.TKSpinBox.pack_forget() element.TKSpinBox.pack_forget()
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
element.TKSpinBox.configure(fg=text_color) element.TKSpinBox.configure(fg=text_color)
@ -12485,7 +12543,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
pad=elementpad, echo_stdout_stderr=element.echo_stdout_stderr) pad=elementpad, echo_stdout_stderr=element.echo_stdout_stderr)
element._TKOut.output.configure(takefocus=0) # make it so that Output does not get focus element._TKOut.output.configure(takefocus=0) # make it so that Output does not get focus
element._TKOut.pack(side=tk.LEFT, expand=False, fill=tk.NONE) element._TKOut.pack(side=tk.LEFT, expand=False, fill=tk.NONE)
if element.Visible is False: if element.visible is False:
element._TKOut.frame.pack_forget() element._TKOut.frame.pack_forget()
if element.Tooltip is not None: if element.Tooltip is not None:
element.TooltipObject = ToolTip(element._TKOut, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME) element.TooltipObject = ToolTip(element._TKOut, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
@ -12523,7 +12581,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# tktext_label.configure(anchor=tk.NW, image=photo) # tktext_label.configure(anchor=tk.NW, image=photo)
element.tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element.tktext_label.pack_forget() element.tktext_label.pack_forget()
if element.Tooltip is not None: if element.Tooltip is not None:
element.TooltipObject = ToolTip(element.tktext_label, text=element.Tooltip, element.TooltipObject = ToolTip(element.tktext_label, text=element.Tooltip,
@ -12546,7 +12604,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
element._TKCanvas.configure(background=element.BackgroundColor, highlightthickness=0) element._TKCanvas.configure(background=element.BackgroundColor, highlightthickness=0)
element._TKCanvas.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element._TKCanvas.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
element._TKCanvas.pack_forget() element._TKCanvas.pack_forget()
if element.Tooltip is not None: if element.Tooltip is not None:
element.TooltipObject = ToolTip(element._TKCanvas, text=element.Tooltip, element.TooltipObject = ToolTip(element._TKCanvas, text=element.Tooltip,
@ -12571,7 +12629,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element._TKCanvas2.configure(background=element.BackgroundColor, highlightthickness=0) element._TKCanvas2.configure(background=element.BackgroundColor, highlightthickness=0)
# element._TKCanvas.configure(background=element.BackgroundColor, highlightthickness=0) # element._TKCanvas.configure(background=element.BackgroundColor, highlightthickness=0)
element._TKCanvas2.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element._TKCanvas2.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
# element._TKCanvas.pack_forget() # element._TKCanvas.pack_forget()
element._TKCanvas2.pack_forget() element._TKCanvas2.pack_forget()
if element.Tooltip is not None: if element.Tooltip is not None:
@ -12637,7 +12695,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.Size != (None, None): if element.Size != (None, None):
labeled_frame.config(width=element.Size[0], height=element.Size[1]) labeled_frame.config(width=element.Size[0], height=element.Size[1])
if not element.Visible: if not element.visible:
labeled_frame.pack_forget() labeled_frame.pack_forget()
if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None:
labeled_frame.configure(background=element.BackgroundColor, labeled_frame.configure(background=element.BackgroundColor,
@ -12664,7 +12722,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
state = 'normal' state = 'normal'
if element.Disabled: if element.Disabled:
state = 'disabled' state = 'disabled'
if element.Visible is False: if element.visible is False:
state = 'hidden' state = 'hidden'
# this code will add an image to the tab. Use it when adding the image on a tab enhancement # this code will add an image to the tab. Use it when adding the image on a tab enhancement
# element.photo_image = tk.PhotoImage(data=DEFAULT_BASE64_ICON) # element.photo_image = tk.PhotoImage(data=DEFAULT_BASE64_ICON)
@ -12772,7 +12830,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
tkscale.configure(fg=text_color) tkscale.configure(fg=text_color)
tkscale.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) tkscale.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.visible is False:
tkscale.pack_forget() tkscale.pack_forget()
element.TKScale = tkscale element.TKScale = tkscale
if element.Disabled == True: if element.Disabled == True:
@ -12901,7 +12959,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
treeview.configure(xscrollcommand=hscrollbar.set) treeview.configure(xscrollcommand=hscrollbar.set)
element.TKTreeview.pack(side=tk.LEFT, expand=True, padx=0, pady=0, fill='both') element.TKTreeview.pack(side=tk.LEFT, expand=True, padx=0, pady=0, fill='both')
if element.Visible is False: if element.visible is False:
element.TKTreeview.pack_forget() element.TKTreeview.pack_forget()
frame.pack(side=tk.LEFT, expand=True, padx=elementpad[0], pady=elementpad[1]) frame.pack(side=tk.LEFT, expand=True, padx=elementpad[0], pady=elementpad[1])
if element.Tooltip is not None: if element.Tooltip is not None:
@ -13017,7 +13075,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
scrollbar.config(command=treeview.yview) scrollbar.config(command=treeview.yview)
treeview.configure(yscrollcommand=scrollbar.set) treeview.configure(yscrollcommand=scrollbar.set)
element.TKTreeview.pack(side=tk.LEFT, expand=True, padx=0, pady=0, fill='both') element.TKTreeview.pack(side=tk.LEFT, expand=True, padx=0, pady=0, fill='both')
if element.Visible is False: if element.visible is False:
element.TKTreeview.pack_forget() element.TKTreeview.pack_forget()
frame.pack(side=tk.LEFT, expand=True, padx=elementpad[0], pady=elementpad[1]) frame.pack(side=tk.LEFT, expand=True, padx=elementpad[0], pady=elementpad[1])
treeview.bind("<<TreeviewSelect>>", element._treeview_selected) treeview.bind("<<TreeviewSelect>>", element._treeview_selected)
@ -13096,7 +13154,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
tktext_label.configure(fg=element.TextColor) tktext_label.configure(fg=element.TextColor)
tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.X, expand=True) tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.X, expand=True)
row_fill_direction = tk.X row_fill_direction = tk.X
if element.Visible is False: if element.visible is False:
tktext_label.pack_forget() tktext_label.pack_forget()
element.TKText = tktext_label element.TKText = tktext_label
if element.ClickSubmits: if element.ClickSubmits: