Turn off grab_anywhere on Demos of realtime buttons due to error message from tkinter
This commit is contained in:
parent
c905acdd3d
commit
fdab86b66f
|
@ -4,7 +4,7 @@ import PySimpleGUI as sg
|
||||||
def Everything():
|
def Everything():
|
||||||
sg.ChangeLookAndFeel('Dark')
|
sg.ChangeLookAndFeel('Dark')
|
||||||
|
|
||||||
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1))
|
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1), grab_anywhere=False)
|
||||||
|
|
||||||
column1 = [[sg.Text('Column 1', background_color='black', justification='center', size=(10, 1))],
|
column1 = [[sg.Text('Column 1', background_color='black', justification='center', size=(10, 1))],
|
||||||
[sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')],
|
[sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')],
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Turn off padding in order to get a really tight looking layout.
|
Turn off padding in order to get a really tight looking layout.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sg.ChangeLookAndFeel('Dark')
|
sg.ChangeLookAndFeel('Dark')
|
||||||
sg.SetOptions(element_padding=(0, 0))
|
sg.SetOptions(element_padding=(0, 0))
|
||||||
layout = [[sg.T('User:', pad=((3, 0), 0)), sg.OptionMenu(values=('User 1', 'User 2'), size=(20, 1)),
|
layout = [[sg.T('User:', pad=((3, 0), 0)), sg.OptionMenu(values=('User 1', 'User 2'), size=(20, 1)),
|
||||||
|
@ -15,10 +16,13 @@ layout = [[sg.T('User:', pad=((3, 0), 0)), sg.OptionMenu(values=('User 1', 'User
|
||||||
sg.ReadFormButton('Reset', button_color=('white', '#9B0023')),
|
sg.ReadFormButton('Reset', button_color=('white', '#9B0023')),
|
||||||
sg.ReadFormButton('Submit', button_color=('gray60', 'springgreen4')),
|
sg.ReadFormButton('Submit', button_color=('gray60', 'springgreen4')),
|
||||||
sg.SimpleButton('Exit', button_color=('white', '#00406B'))]]
|
sg.SimpleButton('Exit', button_color=('white', '#00406B'))]]
|
||||||
|
|
||||||
form = sg.FlexForm("Time Tracker", default_element_size=(12, 1), text_justification='r', auto_size_text=False,
|
form = sg.FlexForm("Time Tracker", default_element_size=(12, 1), text_justification='r', auto_size_text=False,
|
||||||
auto_size_buttons=False, no_titlebar=True,
|
auto_size_buttons=False, no_titlebar=True,
|
||||||
default_button_element_size=(12, 1))
|
default_button_element_size=(12, 1))
|
||||||
|
|
||||||
form.Layout(layout)
|
form.Layout(layout)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
button, values = form.Read()
|
button, values = form.Read()
|
||||||
if button is None or button == 'Exit':
|
if button is None or button == 'Exit':
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
form = sg.FlexForm("Font size selector")
|
|
||||||
|
|
||||||
fontSize = 12
|
fontSize = 12
|
||||||
|
|
||||||
|
@ -12,6 +11,7 @@ layout = [[sg.Spin([sz for sz in range(6, 172)], font=('Helvetica 20'), initial_
|
||||||
sg.Slider(range=(6,172), orientation='h', size=(10,20), change_submits=True, key='slider', font=('Helvetica 20')), sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontSize), key='text')]]
|
sg.Slider(range=(6,172), orientation='h', size=(10,20), change_submits=True, key='slider', font=('Helvetica 20')), sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontSize), key='text')]]
|
||||||
|
|
||||||
sz = fontSize
|
sz = fontSize
|
||||||
|
form = sg.FlexForm("Font size selector", grab_anywhere=False)
|
||||||
form.Layout(layout)
|
form.Layout(layout)
|
||||||
while True:
|
while True:
|
||||||
button, values= form.Read()
|
button, values= form.Read()
|
||||||
|
|
|
@ -14,7 +14,7 @@ def RemoteControlExample():
|
||||||
image_left = 'ButtonGraphics/RobotLeft.png'
|
image_left = 'ButtonGraphics/RobotLeft.png'
|
||||||
image_right = 'ButtonGraphics/RobotRight.png'
|
image_right = 'ButtonGraphics/RobotRight.png'
|
||||||
sg.SetOptions(border_width=0, button_color=('black', back), background_color=back, element_background_color=back, text_element_background_color=back)
|
sg.SetOptions(border_width=0, button_color=('black', back), background_color=back, element_background_color=back, text_element_background_color=back)
|
||||||
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True)
|
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False)
|
||||||
status_display_elem = sg.T('', justification='center', size=(19,1))
|
status_display_elem = sg.T('', justification='center', size=(19,1))
|
||||||
form_rows = [[sg.Text('Robotics Remote Control')],
|
form_rows = [[sg.Text('Robotics Remote Control')],
|
||||||
[status_display_elem],
|
[status_display_elem],
|
||||||
|
@ -49,7 +49,7 @@ def RemoteControlExample():
|
||||||
|
|
||||||
def RemoteControlExample_NoGraphics():
|
def RemoteControlExample_NoGraphics():
|
||||||
# Make a form, but don't use context manager
|
# Make a form, but don't use context manager
|
||||||
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True)
|
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False)
|
||||||
status_display_elem = sg.T('', justification='center', size=(19,1))
|
status_display_elem = sg.T('', justification='center', size=(19,1))
|
||||||
form_rows = [[sg.Text('Robotics Remote Control', justification='center')],
|
form_rows = [[sg.Text('Robotics Remote Control', justification='center')],
|
||||||
[status_display_elem],
|
[status_display_elem],
|
||||||
|
|
|
@ -4,36 +4,31 @@ import time
|
||||||
# form that doen't block
|
# form that doen't block
|
||||||
# good for applications with an loop that polls hardware
|
# good for applications with an loop that polls hardware
|
||||||
def Timer():
|
def Timer():
|
||||||
sg.ChangeLookAndFeel('TealMono')
|
sg.ChangeLookAndFeel('Dark')
|
||||||
# Make a form, but don't use context manager
|
# Make a form, but don't use context manager
|
||||||
form = sg.FlexForm('Running Timer', auto_size_text=True)
|
form = sg.FlexForm('Running Timer', grab_anywhere=False, no_titlebar=True, auto_size_buttons=False)
|
||||||
# Create a text element that will be updated with status information on the GUI itself
|
# Create a text element that will be updated with status information on the GUI itself
|
||||||
# Create the rows
|
# Create the rows
|
||||||
form_rows = [[sg.Text('Stopwatch')],
|
form_rows = [[sg.Text('Stopwatch')],
|
||||||
[sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center', key='text')],
|
[sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center', key='text')],
|
||||||
[sg.ReadFormButton('Pause/Resume'), sg.ReadFormButton('Reset')]]
|
[sg.ReadFormButton('Pause'), sg.ReadFormButton('Reset'), sg.Exit()]]
|
||||||
# Layout the rows of the form and perform a read. Indicate the form is non-blocking!
|
# Layout the rows of the form and perform a read. Indicate the form is non-blocking!
|
||||||
form.LayoutAndRead(form_rows, non_blocking=True)
|
form.Layout(form_rows)
|
||||||
|
|
||||||
#
|
|
||||||
# Some place later in your code...
|
|
||||||
# You need to perform a ReadNonBlocking on your form every now and then or
|
|
||||||
# else it won't refresh.
|
|
||||||
#
|
#
|
||||||
# your program's main loop
|
# your program's main loop
|
||||||
i = 0
|
i = 0
|
||||||
paused = False
|
paused = False
|
||||||
while (True):
|
while (True):
|
||||||
# This is the code that reads and updates your window
|
# This is the code that reads and updates your window
|
||||||
form.FindElement('text').Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
|
|
||||||
button, values = form.ReadNonBlocking()
|
button, values = form.ReadNonBlocking()
|
||||||
|
form.FindElement('text').Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
|
||||||
|
|
||||||
if values is None:
|
if values is None or button == 'Exit':
|
||||||
break
|
break
|
||||||
|
|
||||||
if button is 'Reset':
|
if button is 'Reset':
|
||||||
i=0
|
i=0
|
||||||
elif button is 'Pause/Resume':
|
elif button is 'Pause':
|
||||||
paused = not paused
|
paused = not paused
|
||||||
|
|
||||||
if not paused:
|
if not paused:
|
||||||
|
|
Loading…
Reference in New Issue