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