diff --git a/DemoPrograms/Demo_Spinner_Compound_Element.py b/DemoPrograms/Demo_Spinner_Compound_Element.py index 2108c250..f8059fee 100644 --- a/DemoPrograms/Demo_Spinner_Compound_Element.py +++ b/DemoPrograms/Demo_Spinner_Compound_Element.py @@ -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()