From d48b44473486254d1ed1fccf0bc7a42ff7a3b9e9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 29 Aug 2019 11:19:30 -0400 Subject: [PATCH] Fixed focus inside containers problem --- PySimpleGUI.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index c537e11e..afc0fb5d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -version = __version__ = "4.4.0.4 Unreleased Version" +version = __version__ = "4.4.0.5 Unreleased Version" # 888888ba .d88888b oo dP .88888. dP dP dP @@ -5076,6 +5076,7 @@ class Window: self.DebuggerEnabled = debugger_enabled self.WasClosed = False self.ElementJustification = element_justification + self.FocusSet = False 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) not in (list, tuple): @@ -7386,7 +7387,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): # **************** Use FlexForm to build the tkinter window ********** ----- # # Building is done row by row. # # --------------------------------------------------------------------------- # - focus_set = False ######################### LOOP THROUGH ROWS ######################### # *********** ------- Loop through ROWS ------- ***********# for row_num, flex_row in enumerate(form.Rows): @@ -7662,8 +7662,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): tkbutton.pack_forget() if element.BindReturnKey: element.TKButton.bind('', element._ReturnKeyHandler) - if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): - focus_set = True + if element.Focus is True or (toplevel_form.UseDefaultFocus and not toplevel_form.FocusSet): + toplevel_form.FocusSet = True element.TKButton.bind('', element._ReturnKeyHandler) element.TKButton.focus_set() toplevel_form.TKroot.focus_force() @@ -7773,8 +7773,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): element.TKEntry.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill=tk.X) if element.Visible is False: element.TKEntry.pack_forget() - if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): - focus_set = True + if element.Focus is True or (toplevel_form.UseDefaultFocus and not toplevel_form.FocusSet): + toplevel_form.FocusSet = True element.TKEntry.focus_set() if element.Disabled: element.TKEntry['state'] = 'readonly' @@ -7963,8 +7963,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): element.TKText.bind('', element._KeyboardHandler) if element.EnterSubmits: element.TKText.bind('', element._ReturnKeyHandler) - if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): - focus_set = True + if element.Focus is True or (toplevel_form.UseDefaultFocus and not toplevel_form.FocusSet): + toplevel_form.FocusSet = True element.TKText.focus_set() if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: element.TKText.configure(fg=text_color)