Refresh of Demo applications
This commit is contained in:
parent
7e1ff1d543
commit
8f220a7ac1
9 changed files with 139 additions and 87 deletions
|
@ -44,18 +44,14 @@ def StatusOutputExample():
|
|||
|
||||
def RemoteControlExample():
|
||||
# Make a form, but don't use context manager
|
||||
form = sg.FlexForm('Running Timer', auto_size_text=True)
|
||||
# Create a text element that will be updated with status information on the GUI itself
|
||||
output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center')
|
||||
|
||||
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True)
|
||||
|
||||
form_rows = [[sg.Text('Robotics Remote Control')],
|
||||
[output_element],
|
||||
[sg.T(' '*10), sg.RealtimeButton('Forward')],
|
||||
[ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')],
|
||||
[sg.T(' '*10), sg.RealtimeButton('Reverse')],
|
||||
[sg.T('')],
|
||||
[sg.Quit()]
|
||||
[sg.Quit(button_color=('black', 'orange'))]
|
||||
]
|
||||
|
||||
form.LayoutAndRead(form_rows, non_blocking=True)
|
||||
|
@ -66,25 +62,15 @@ def RemoteControlExample():
|
|||
# else it won't refresh.
|
||||
#
|
||||
# your program's main loop
|
||||
i=0
|
||||
while (True):
|
||||
# This is the code that reads and updates your window
|
||||
output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
|
||||
button, values = form.ReadNonBlocking()
|
||||
if button is not None:
|
||||
print(button)
|
||||
sg.Print(button)
|
||||
if button == 'Quit' or values is None:
|
||||
break
|
||||
if button == 'LED On':
|
||||
print('Turning on the LED')
|
||||
elif button == 'LED Off':
|
||||
print('Turning off the LED')
|
||||
# time.sleep(.01)
|
||||
|
||||
i += 1
|
||||
# Your code begins here
|
||||
time.sleep(.01)
|
||||
|
||||
# Broke out of main loop. Close the window.
|
||||
form.CloseNonBlockingForm()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue