commit
664ed3d9ab
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
Demo Spin Element - Wraps around
|
||||||
|
|
||||||
|
This is a nice touch for the Spin Element that is yet another jason990420 creation
|
||||||
|
|
||||||
|
This Spin element will wrap around going in either direction. When getting to the end then
|
||||||
|
it will go back to the beginning.
|
||||||
|
|
||||||
|
Copyright 2021 PySimpleGUI
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
lower, upper = 0, 10
|
||||||
|
data = [i for i in range(lower - 1, upper + 2)]
|
||||||
|
|
||||||
|
layout = [[sg.Spin(data, initial_value=lower, readonly=True, size=3, enable_events=True, key='-SPIN-')]]
|
||||||
|
|
||||||
|
window = sg.Window('Title', layout, font='_ 18')
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
event, values = window.read()
|
||||||
|
|
||||||
|
if event == sg.WIN_CLOSED:
|
||||||
|
break
|
||||||
|
|
||||||
|
# code to make the Spin do the wrap around. Do this prior to using the Spin's value in your code
|
||||||
|
if event == '-SPIN-':
|
||||||
|
value = values['-SPIN-']
|
||||||
|
if value == lower - 1:
|
||||||
|
window['-SPIN-'].update(value=upper)
|
||||||
|
values['-SPIN-'] = upper # Change the values dictionary too so it'll be correct if used
|
||||||
|
elif value == upper + 1:
|
||||||
|
window['-SPIN-'].update(value=lower)
|
||||||
|
values['-SPIN-'] = lower # Change the values dictionary too so it'll be correct if used
|
||||||
|
|
||||||
|
print(values['-SPIN-'])
|
||||||
|
|
||||||
|
window.close()
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
version = __version__ = "4.59.0.25 Released 5-Apr-2022"
|
version = __version__ = "4.59.0.26 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
|
||||||
|
@ -91,6 +91,8 @@ _change_log = """
|
||||||
Support for the GrayGrayGray theme with the new ttk scrollbars... for those that like the grayscale world, you're now safe
|
Support for the GrayGrayGray theme with the new ttk scrollbars... for those that like the grayscale world, you're now safe
|
||||||
4.59.0.25
|
4.59.0.25
|
||||||
Fix for systems that don't yet have the ttk scrollbars set up. Was getting the incorrect defaults (they were all blank)
|
Fix for systems that don't yet have the ttk scrollbars set up. Was getting the incorrect defaults (they were all blank)
|
||||||
|
4.59.0.26
|
||||||
|
Debug window - betting re-opening code so that the data is not missed from being printed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
||||||
|
@ -10958,6 +10960,24 @@ class Window:
|
||||||
self.Rows = None
|
self.Rows = None
|
||||||
self.TKroot = None
|
self.TKroot = None
|
||||||
|
|
||||||
|
def is_closed(self):
|
||||||
|
"""
|
||||||
|
Returns True is the window is maybe closed. Can be difficult to tell sometimes
|
||||||
|
|
||||||
|
:return: True if the window was closed or destroyed
|
||||||
|
:rtype: (bool)
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self.TKrootDestroyed or self.TKroot is None:
|
||||||
|
return True
|
||||||
|
# see if can do an update... if not, then it's been destroyed
|
||||||
|
try:
|
||||||
|
rc = self.TKroot.update()
|
||||||
|
except:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
# IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called
|
# IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called
|
||||||
def _OnClosingCallback(self):
|
def _OnClosingCallback(self):
|
||||||
"""
|
"""
|
||||||
|
@ -17242,16 +17262,20 @@ class _DebugWin():
|
||||||
font=font or ('Courier New', 10), grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, finalize=True, resizable=resizable)
|
font=font or ('Courier New', 10), grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, finalize=True, resizable=resizable)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def reopen_window(self):
|
||||||
|
if self.window is None or (self.window is not None and self.window.is_closed()):
|
||||||
|
self.__init__(size=self.size, location=self.location, relative_location=self.relative_location, font=self.font, no_titlebar=self.no_titlebar,
|
||||||
|
no_button=self.no_button, grab_anywhere=self.grab_anywhere, keep_on_top=self.keep_on_top,
|
||||||
|
do_not_reroute_stdout=self.do_not_reroute_stdout, resizable=self.resizable, echo_stdout=self.echo_stdout)
|
||||||
|
|
||||||
|
|
||||||
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
|
global SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
|
||||||
suppress = SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
|
suppress = SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
|
||||||
SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS = True
|
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
|
self.reopen_window() # if needed, open the window again
|
||||||
self.__init__(size=self.size, location=self.location, relative_location=self.relative_location, font=self.font, no_titlebar=self.no_titlebar,
|
|
||||||
no_button=self.no_button, grab_anywhere=self.grab_anywhere, keep_on_top=self.keep_on_top,
|
|
||||||
do_not_reroute_stdout=self.do_not_reroute_stdout, resizable=self.resizable, echo_stdout=self.echo_stdout, blocking=blocking)
|
|
||||||
|
|
||||||
timeout = 0 if not blocking else None
|
timeout = 0 if not blocking else None
|
||||||
if erase_all:
|
if erase_all:
|
||||||
|
@ -17268,7 +17292,13 @@ class _DebugWin():
|
||||||
if i != num_args - 1:
|
if i != num_args - 1:
|
||||||
outstring += sep_str
|
outstring += sep_str
|
||||||
outstring += end_str
|
outstring += end_str
|
||||||
|
try:
|
||||||
self.output_element.update(outstring, append=True, text_color_for_value=text_color, background_color_for_value=background_color, font_for_value=font)
|
self.output_element.update(outstring, append=True, text_color_for_value=text_color, background_color_for_value=background_color, font_for_value=font)
|
||||||
|
except:
|
||||||
|
self.window=None
|
||||||
|
self.reopen_window()
|
||||||
|
self.output_element.update(outstring, append=True, text_color_for_value=text_color, background_color_for_value=background_color, font_for_value=font)
|
||||||
|
|
||||||
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
|
||||||
|
@ -17277,13 +17307,13 @@ class _DebugWin():
|
||||||
try: # The window may be closed by user at any time, so have to protect
|
try: # The window may be closed by user at any time, so have to protect
|
||||||
self.quit_button.update(text='Click to continue...')
|
self.quit_button.update(text='Click to continue...')
|
||||||
except:
|
except:
|
||||||
pass
|
self.window = None
|
||||||
else:
|
else:
|
||||||
self.quit_button.BType = BUTTON_TYPE_CLOSES_WIN_ONLY
|
self.quit_button.BType = BUTTON_TYPE_CLOSES_WIN_ONLY
|
||||||
try: # The window may be closed by user at any time, so have to protect
|
try: # The window may be closed by user at any time, so have to protect
|
||||||
self.quit_button.update(text='Quit')
|
self.quit_button.update(text='Quit')
|
||||||
except:
|
except:
|
||||||
pass
|
self.window = None
|
||||||
|
|
||||||
try: # The window may be closed by user at any time, so have to protect
|
try: # The window may be closed by user at any time, so have to protect
|
||||||
if blocking:
|
if blocking:
|
||||||
|
@ -17291,7 +17321,9 @@ class _DebugWin():
|
||||||
else:
|
else:
|
||||||
self.window['-PAUSE-'].update(visible=True)
|
self.window['-PAUSE-'].update(visible=True)
|
||||||
except:
|
except:
|
||||||
pass
|
self.window = None
|
||||||
|
|
||||||
|
self.reopen_window() # if needed, open the window again
|
||||||
|
|
||||||
paused = None
|
paused = None
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue