diff --git a/DemoPrograms/Demo_Invisible_Elements.py b/DemoPrograms/Demo_Invisible_Elements.py new file mode 100644 index 00000000..df98d4bd --- /dev/null +++ b/DemoPrograms/Demo_Invisible_Elements.py @@ -0,0 +1,27 @@ +import PySimpleGUI as sg + +""" + Demonstrates that using a Column Element to make groups of Elements appear and disappear + will cause the layout of the elements in the column to remain as they were. If each individual element + were made invisible and then visible, then tkinter puts EACH ELEMENT on a separate row when it is made + visible again. This means a row of 6 elements will become a column of 6 elements if you make each of them + visible one at a time. + +""" + +layout = [[sg.Column([[sg.Text('My Window')],[sg.Input(key='_IN_'), sg.B('My button', key='_OUT_')]], key='_COL_')], + [sg.Button('Invisible'), sg.B('Visible'), sg.Button('Exit')]] + +window = sg.Window('Window Title', layout) + +while True: # Event Loop + event, values = window.Read() + print(event, values) + if event in (None, 'Exit'): + break + if event == 'Invisible': + window.Elem('_COL_').Update(visible=False) + elif event == 'Visible': + window.Elem('_COL_').Update(visible=True) + +window.Close() diff --git a/PySimpleGUI.py b/PySimpleGUI.py index b133be19..a4d1cf1f 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -2748,7 +2748,7 @@ class Graph(Element): self.BottomLeft = graph_bottom_left self.TopRight = graph_top_right # self._TKCanvas = None # type: tk.Canvas - self._TKCanvas2 = None # type: tk.Canvas + self._TKCanvas2 = self.Widget = None # type: tk.Canvas self.ChangeSubmits = change_submits or enable_events self.DragSubmits = drag_submits self.ClickPosition = (None, None) @@ -3697,16 +3697,16 @@ class Slider(Element): # ---------------------------------------------------------------------- # -# TkScrollableFrame (Used by Column) # +# TkFixedFrame (Used by Column) # # ---------------------------------------------------------------------- # class TkFixedFrame(tk.Frame): - """ """ + """ + A tkinter frame that is used with Column Elements that do not have a scrollbar + """ def __init__(self, master, **kwargs): """ - - :param master: - :param **kwargs: - + :param master: (tk.Widget) The parent widget + :param **kwargs: The keyword args """ tk.Frame.__init__(self, master, **kwargs) @@ -3730,17 +3730,17 @@ class TkFixedFrame(tk.Frame): # TkScrollableFrame (Used by Column) # # ---------------------------------------------------------------------- # class TkScrollableFrame(tk.Frame): - """ """ + """ + A frame with one or two scrollbars. Used to make Columns with scrollbars + """ def __init__(self, master, vertical_only, **kwargs): """ - :param master: ???????????????????????? - :param vertical_only: ???????????????????????? - :param **kwargs: - + :param master: (tk.Widget) The parent widget + :param vertical_only: (bool) if True the only a vertical scrollbar will be shown + :param **kwargs: The keyword parms """ tk.Frame.__init__(self, master, **kwargs) - # create a canvas object and a vertical scrollbar for scrolling it self.vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL) self.vscrollbar.pack(side='right', fill="y", expand="false") @@ -5000,6 +5000,12 @@ class Window: self.TransparentColor = transparent_color self.UniqueKeyCounter = 0 self.DebuggerEnabled = debugger_enabled + + if type(title) != str: + warnings.warn('Your title is not a string. Are you passing in the right parameters?', UserWarning) + if layout is not None and type(layout) != list: + warnings.warn('Your layout is not a list... this is not good!') + if layout is not None: self.Layout(layout)