From c48b236bcea69003ceb28773184b82da437d8035 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 31 Jul 2019 13:29:03 -0400 Subject: [PATCH 1/2] Added a general "SetFocus" to Element as a "catch all". Utilizes .Widget so hope they all are being set. Added 'Elem' shortcut for FindElement. --- PySimpleGUI.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 58952d6f..56aaf926 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -728,6 +728,22 @@ class Element(): """ self.TooltipObject = ToolTip(self.Widget, text=tooltip_text, timeout=DEFAULT_TOOLTIP_TIME) + def SetFocus(self, force=False): + """ + Sets the current focus to be on this element + + :param force: (bool) if True will call focus_force otherwise calls focus_set + """ + + try: + if force: + self.Widget.focus_force() + else: + self.Widget.focus_set() + except: + print('Was unable to set focus. The Widget passed in was perhaps not present in this element? Check your elements .Widget property') + + def __del__(self): """ """ try: @@ -5460,9 +5476,9 @@ class Window: element = ErrorElement(key=key) return element - Element = FindElement # Shortcut function - Find = FindElement - + Element = FindElement # Shortcut function + Find = FindElement # Shortcut function, most likely not used by many people. + Elem = FindElement # NEW for 2019! More laziness... Another shortcut def FindElementWithFocus(self): """ From 6ea3dbed4108429382f28a64b4f5b71ee888cc22 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 31 Jul 2019 13:29:28 -0400 Subject: [PATCH 2/2] Version bump --- PySimpleGUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 56aaf926..9e1b4ec5 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -version = __version__ = "4.1.0.17 Unreleased - Anniversary Edition" +version = __version__ = "4.1.0.18 Unreleased - Anniversary Edition" # 888888ba .d88888b oo dP .88888. dP dP dP