Merge pull request #5331 from PySimpleGUI/Dev-latest

Addition of  flag to turn off the widget not created errors. Gets aro…
This commit is contained in:
PySimpleGUI 2022-04-06 15:20:18 -04:00 committed by GitHub
commit 32d5481f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 10 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.59.0.1 Released 5-Apr-2022" version = __version__ = "4.59.0.2 Released 5-Apr-2022"
_change_log = """ _change_log = """
Changelog since 4.59.0 released to PyPI on 5-Apr-2022 Changelog since 4.59.0 released to PyPI on 5-Apr-2022
@ -8,7 +8,10 @@ _change_log = """
4.59.0.1 4.59.0.1
Addition of the blocking parameter to the Print function. Enables using Print through an entire program with the last Addition of the blocking parameter to the Print function. Enables using Print through an entire program with the last
Print call setting the blocking parameter so that the window doesn't close until user interacts with the Debug Output Window Print call setting the blocking parameter so that the window doesn't close until user interacts with the Debug Output Window
4.59.0.2
Added SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS as a way to turn off checking for widgets to be finalized. Needed to get around some race conditions.
It's possible (likely) that a debug window is closed while printing to the debug window. This would normally generate an error. Use this flag to
turn off this error checking temporarily
""" """
@ -606,7 +609,7 @@ CUSTOM_MENUBAR_METADATA_MARKER = 'This is a custom menubar'
SUPPRESS_ERROR_POPUPS = False SUPPRESS_ERROR_POPUPS = False
SUPPRESS_RAISE_KEY_ERRORS = True SUPPRESS_RAISE_KEY_ERRORS = True
SUPPRESS_KEY_GUESSING = False SUPPRESS_KEY_GUESSING = False
SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS = False
ENABLE_TREEVIEW_869_PATCH = True ENABLE_TREEVIEW_869_PATCH = True
# These are now set based on the global settings file # These are now set based on the global settings file
@ -1549,8 +1552,10 @@ class Element():
if self.Widget is not None: if self.Widget is not None:
return True return True
else: else:
warnings.warn('You cannot Update element with key = {} until the window.read() is called or finalized=True when creating window'.format(self.Key), if SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS:
UserWarning) return False
warnings.warn('You cannot Update element with key = {} until the window.read() is called or finalized=True when creating window'.format(self.Key), UserWarning)
if not SUPPRESS_ERROR_POPUPS: if not SUPPRESS_ERROR_POPUPS:
_error_popup_with_traceback('Unable to complete operation on element with key {}'.format(self.Key), _error_popup_with_traceback('Unable to complete operation on element with key {}'.format(self.Key),
'You cannot perform operations (such as calling update) on an Element until:', 'You cannot perform operations (such as calling update) on an Element until:',
@ -16739,6 +16744,9 @@ class _DebugWin():
return return
def Print(self, *args, end=None, sep=None, text_color=None, background_color=None, erase_all=False, font=None, blocking=None): def Print(self, *args, end=None, sep=None, text_color=None, background_color=None, erase_all=False, font=None, blocking=None):
global SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
suppress = SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS = True
sepchar = sep if sep is not None else ' ' sepchar = sep if sep is not None else ' '
endchar = end if end is not None else '\n' endchar = end if end is not None else '\n'
if self.window is None: # if window was destroyed already re-open it if self.window is None: # if window was destroyed already re-open it
@ -16771,10 +16779,10 @@ class _DebugWin():
else: else:
print(*args, sep=sepchar, end=endchar) print(*args, sep=sepchar, end=endchar)
# This is tricky....changing the button type depending on the blocking parm. If blocking, then the "Quit" button should become a normal button # This is tricky....changing the button type depending on the blocking parm. If blocking, then the "Quit" button should become a normal button
if blocking: if blocking and blocking != self.blocking:
self.quit_button.BType = BUTTON_TYPE_READ_FORM self.quit_button.BType = BUTTON_TYPE_READ_FORM
self.quit_button.update(text='More') self.quit_button.update(text='More')
else: elif blocking != self.blocking:
self.quit_button.BType = BUTTON_TYPE_CLOSES_WIN_ONLY self.quit_button.BType = BUTTON_TYPE_CLOSES_WIN_ONLY
self.quit_button.update(text='Quit') self.quit_button.update(text='Quit')
@ -16782,6 +16790,8 @@ class _DebugWin():
if event == WIN_CLOSED or (not blocking and event == 'Quit'): if event == WIN_CLOSED or (not blocking and event == 'Quit'):
self.Close() self.Close()
SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS = suppress
def Close(self): def Close(self):
if self.window.XFound: # increment the number of open windows to get around a bug with debug windows if self.window.XFound: # increment the number of open windows to get around a bug with debug windows
Window._IncrementOpenCount() Window._IncrementOpenCount()
@ -16790,8 +16800,7 @@ class _DebugWin():
def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, None), relative_location=(None, None), font=None, no_titlebar=False, def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, None), relative_location=(None, None), font=None, no_titlebar=False,
no_button=False, grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, text_color=None, background_color=None, colors=None, c=None, no_button=False, grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, text_color=None, background_color=None, colors=None, c=None, erase_all=False, resizable=True, blocking=None):
erase_all=False, resizable=True, blocking=None):
""" """
Works like a "print" statement but with windowing options. Routes output to the "Debug Window" Works like a "print" statement but with windowing options. Routes output to the "Debug Window"