Added some text, added use of Debug Window to display values since may be running from the Demo Browser where prints are not shown

This commit is contained in:
PySimpleGUI 2022-04-21 12:44:36 -04:00
parent 40567418db
commit ee7179fb3a
1 changed files with 6 additions and 5 deletions

View File

@ -10,16 +10,17 @@ import PySimpleGUI as sg
This Spin element will wrap around going in either direction. When getting to the end then This Spin element will wrap around going in either direction. When getting to the end then
it will go back to the beginning. it will go back to the beginning.
Copyright 2021 PySimpleGUI Copyright 2022 PySimpleGUI
""" """
lower, upper = 0, 10 lower, upper = 0, 10
data = [i for i in range(lower - 1, upper + 2)] 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-')]] layout = [[sg.Text('This Spin element wraps around in both directions')],
[sg.Spin(data, initial_value=lower, readonly=True, size=3, enable_events=True, key='-SPIN-')]]
window = sg.Window('Title', layout, font='_ 18') window = sg.Window('Wrapping Spin Element', layout, font='_ 18', keep_on_top=True)
while True: while True:
@ -27,7 +28,7 @@ while True:
if event == sg.WIN_CLOSED: if event == sg.WIN_CLOSED:
break break
# code to make the Spin do the wrap around. Do this prior to using the Spin's value in your code # code to make the Spin do the wrap around. Do this prior to using the Spin's value in your code
if event == '-SPIN-': if event == '-SPIN-':
value = values['-SPIN-'] value = values['-SPIN-']
@ -38,6 +39,6 @@ while True:
window['-SPIN-'].update(value=lower) window['-SPIN-'].update(value=lower)
values['-SPIN-'] = lower # Change the values dictionary too so it'll be correct if used values['-SPIN-'] = lower # Change the values dictionary too so it'll be correct if used
print(values['-SPIN-']) sg.Print('Spin Value:', values['-SPIN-'], relative_location=(-400, 0))
window.close() window.close()