diff --git a/PySimpleGUI.py b/PySimpleGUI.py index ac4db16b..62325574 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -541,6 +541,8 @@ class Element(): self.TKRightClickMenu = None self.Widget = None # Set when creating window. Has the main tkinter widget for element self.Tearoff = False + self.ParentRowFrame = None # type tk.Frame + def _RightClickMenuCallback(self, event): """ @@ -7245,6 +7247,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): tk_row_frame = tk.Frame(containing_frame) row_should_expand = False for col_num, element in enumerate(flex_row): + element.ParentRowFrame = tk_row_frame element.ParentForm = toplevel_form # save the button's parent form object if toplevel_form.Font and (element.Font == DEFAULT_FONT or not element.Font): font = toplevel_form.Font @@ -7322,7 +7325,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): element.TKColFrame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') if element.Visible is False: element.TKColFrame.pack_forget() - # element.TKColFrame = element.TKColFrame # if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: # element.TKColFrame.configure(background=element.BackgroundColor, diff --git a/PySimpleGUIQt/PySimpleGUIQt.py b/PySimpleGUIQt/PySimpleGUIQt.py index 3e8f8f96..2e463e51 100644 --- a/PySimpleGUIQt/PySimpleGUIQt.py +++ b/PySimpleGUIQt/PySimpleGUIQt.py @@ -484,6 +484,20 @@ class Element(): set_widget_visiblity(widget, visible) + def __call__(self, *args, **kwargs): + """ + Makes it possible to "call" an already existing element. When you do make the "call", it actually calls + the Update method for the element. + Example: If this text element was in yoiur layout: + sg.Text('foo', key='T') + Then you can call the Update method for that element by writing: + window.FindElement('T')('new text value') + + :param args: + :param kwargs: + :return: + """ + return self.Update(*args, **kwargs) def __del__(self): try: @@ -3159,7 +3173,7 @@ class Window: progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, force_toplevel=False, alpha_channel=1, return_keyboard_events=False, use_default_focus=True, text_justification=None, - no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=True, disable_close=False, disable_minimize=False, background_image=None): + no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=True, disable_close=False, disable_minimize=False, background_image=None, finalize=False): ''' :param title: @@ -3250,6 +3264,8 @@ class Window: if layout is not None: self.Layout(layout) + if finalize: + self.Finalize() @classmethod def IncrementOpenCount(self): @@ -3835,6 +3851,36 @@ class Window: for element in row: element.__del__() + add_row = AddRow + add_rows = AddRows + alpha_channel = AlphaChannel + bring_to_front = BringToFront + close = Close + current_location = CurrentLocation + disable = Disable + disappear = Disappear + element = Element + enable = Enable + fill = Fill + finalize = Finalize + find_element = FindElement + find_element_with_focus = FindElementWithFocus + get_screen_dimensions = GetScreenDimensions + hide = Hide + layout = Layout + load_from_disk = LoadFromDisk + maximize = Maximize + minimize = Minimize + move = Move + read = Read + reappear = Reappear + refresh = Refresh + save_to_disk = SaveToDisk + set_alpha = SetAlpha + set_icon = SetIcon + size = Size + un_hide = UnHide + visibility_changed = VisibilityChanged FlexForm = Window @@ -5071,6 +5117,7 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): qt_row_layout.addWidget(element.QT_TextEdit) # ------------------------- OUTPUT MULTI LINE element ------------------------- # elif element_type == ELEM_TYPE_MULTILINE_OUTPUT: + element = element # type: MultilineOutput default_text = element.DefaultText width, height = element_size element.Widget = element.QT_TextBrowser = QTextBrowser() @@ -5102,6 +5149,7 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): qt_row_layout.addWidget(element.QT_TextBrowser) # ------------------------- INPUT CHECKBOX element ------------------------- # elif element_type == ELEM_TYPE_INPUT_CHECKBOX: + element = element # type: Checkbox element.QT_Checkbox = QCheckBox(element.Text) element.QT_Checkbox.setChecked(element.InitialState) if element.Disabled: diff --git a/PySimpleGUIWeb/PySimpleGUIWeb.py b/PySimpleGUIWeb/PySimpleGUIWeb.py index 6e1df36b..0a2ab68a 100644 --- a/PySimpleGUIWeb/PySimpleGUIWeb.py +++ b/PySimpleGUIWeb/PySimpleGUIWeb.py @@ -501,6 +501,23 @@ class Element(): elif visible is True: del(widget.attributes['hidden']) + + def __call__(self, *args, **kwargs): + """ + Makes it possible to "call" an already existing element. When you do make the "call", it actually calls + the Update method for the element. + Example: If this text element was in yoiur layout: + sg.Text('foo', key='T') + Then you can call the Update method for that element by writing: + window.FindElement('T')('new text value') + + :param args: + :param kwargs: + :return: + """ + return self.Update(*args, **kwargs) + + def __del__(self): pass @@ -2883,7 +2900,7 @@ class Window: auto_close_duration=None, icon=DEFAULT_BASE64_ICON, force_toplevel=False, alpha_channel=1, return_keyboard_events=False, return_key_down_events=False, use_default_focus=True, text_justification=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=True, disable_close=False, - disable_minimize=False, background_image=None, + disable_minimize=False, background_image=None, finalize=False, web_debug=False, web_ip='0.0.0.0', web_port=0, web_start_browser=True, web_update_interval=.0000001, web_multiple_instance=False ): ''' @@ -2992,6 +3009,8 @@ class Window: if layout is not None: self.Layout(layout) + if finalize: + self.Finalize() @classmethod def IncrementOpenCount(self):