Updated to use actual arrows. Much cleaner looking now.

This commit is contained in:
PySimpleGUI 2020-01-02 19:07:59 -05:00
parent 1504cb8d44
commit 962cd61fdc
1 changed files with 12 additions and 19 deletions

View File

@ -6,33 +6,26 @@ import PySimpleGUI as sg
"""
sg.set_options(element_padding=(0, 0))
# sg.theme('Dark')
# --- Define our "Big-Button-Spinner" compound element. Has 2 buttons and an input field --- #
NewSpinner = [sg.Button('-', size=(2, 1), font='Any 12'),
sg.Input('0', size=(2, 1), font='Any 14',
justification='r', key='spin'),
sg.Button('+', size=(2, 1), font='Any 12')]
# --- Define the Compound Element. Has 2 buttons and an input field --- #
NewSpinner = [sg.Input('0', size=(3, 1), font='Any 12', justification='r', key='-SPIN-'),
sg.Column([[sg.Button('', size=(1, 1), font='Any 7', border_width=0, button_color=(sg.theme_text_color(), sg.theme_background_color()), key='-UP-')],
[sg.Button('', size=(1, 1), font='Any 7', border_width=0, button_color=(sg.theme_text_color(), sg.theme_background_color()), key='-DOWN-')]])]
# --- Define Window --- #
layout = [
[sg.Text('Spinner simulation')],
NewSpinner,
[sg.Text('')],
[sg.Ok()]
]
window = sg.Window('Spinner simulation', layout)
layout = [[sg.Text('Spinner simulation')],
NewSpinner,
[sg.Text('')],
[sg.Ok()]]
window = sg.Window('Spinner simulation', layout, use_default_focus=False)
# --- Event Loop --- #
counter = 0
while True:
event, values = window.read()
if event == 'Ok' or event is None: # be nice to your user, always have an exit from your form
break
counter = int(values['-SPIN-'])
# --- do spinner stuff --- #
counter += 1 if event == '+' else -1 if event == '-' else 0
window['spin'].update(counter)
counter += 1 if event == '-UP-' else -1 if event == '-DOWN-' else 0
window['-SPIN-'].update(counter)
window.close()