NEW Demos - Floating CPU utlization widget, Compound element - Spinner, refresh of the other Demos
This commit is contained in:
parent
18584aa533
commit
57396f3dc1
8 changed files with 109 additions and 17 deletions
34
Demo_Spinner_Compound_Element.py
Normal file
34
Demo_Spinner_Compound_Element.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
import PySimpleGUI as sg
|
||||
|
||||
"""
|
||||
Demo of how to combine elements into your own custom element
|
||||
"""
|
||||
|
||||
sg.SetOptions(element_padding=(0,0))
|
||||
sg.ChangeLookAndFeel('Dark')
|
||||
# --- Define our "Big-Button-Spinner" compound element. Has 2 buttons and an input field --- #
|
||||
NewSpinner = [sg.ReadFormButton('-', size=(4,1), font='Any 12'),
|
||||
sg.In('0', size=(5,1), font='Any 14', justification='r', key='spin'),
|
||||
sg.ReadFormButton('+', size=(4,1), font='Any 12')]
|
||||
# --- Define Window --- #
|
||||
layout = [
|
||||
[sg.Text('Spinner simulation')],
|
||||
NewSpinner,
|
||||
[sg.T('')],
|
||||
[sg.Ok()]
|
||||
]
|
||||
|
||||
form = sg.FlexForm('Spinner simulation')
|
||||
form.Layout(layout)
|
||||
|
||||
# --- Event Loop --- #
|
||||
counter = 0
|
||||
while True:
|
||||
button, value = form.Read()
|
||||
|
||||
if button == 'Ok' or button is None: # be nice to your user, always have an exit from your form
|
||||
break
|
||||
|
||||
# --- do spinner stuff --- #
|
||||
counter += 1 if button =='+' else -1 if button == '-' else 0
|
||||
form.FindElement('spin').Update(counter)
|
Loading…
Add table
Add a link
Reference in a new issue