2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
2018-09-12 20:46:35 +00:00
|
|
|
"""
|
|
|
|
Demo of how to combine elements into your own custom element
|
|
|
|
"""
|
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
sg.set_options(element_padding=(0, 0))
|
2019-12-24 23:52:47 +00:00
|
|
|
# sg.theme('Dark')
|
2018-09-12 20:46:35 +00:00
|
|
|
# --- Define our "Big-Button-Spinner" compound element. Has 2 buttons and an input field --- #
|
2019-10-23 20:10:03 +00:00
|
|
|
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')]
|
2018-09-12 20:46:35 +00:00
|
|
|
# --- Define Window --- #
|
|
|
|
layout = [
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.Text('Spinner simulation')],
|
|
|
|
NewSpinner,
|
|
|
|
[sg.Text('')],
|
|
|
|
[sg.Ok()]
|
|
|
|
]
|
|
|
|
|
|
|
|
window = sg.Window('Spinner simulation', layout)
|
2018-09-12 20:46:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
# --- Event Loop --- #
|
|
|
|
counter = 0
|
|
|
|
while True:
|
2019-10-23 20:10:03 +00:00
|
|
|
event, values = window.read()
|
2018-09-12 20:46:35 +00:00
|
|
|
|
2018-10-15 20:07:23 +00:00
|
|
|
if event == 'Ok' or event is None: # be nice to your user, always have an exit from your form
|
2018-09-12 20:46:35 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
# --- do spinner stuff --- #
|
2018-10-15 20:07:23 +00:00
|
|
|
counter += 1 if event == '+' else -1 if event == '-' else 0
|
2019-10-23 20:10:03 +00:00
|
|
|
window['spin'].update(counter)
|
|
|
|
|
|
|
|
window.close()
|