Skip to content

Commit fdab86b

Browse files
Turn off grab_anywhere on Demos of realtime buttons due to error message from tkinter
1 parent c905acd commit fdab86b

5 files changed

Lines changed: 16 additions & 17 deletions

File tree

Demo_All_Widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def Everything():
55
sg.ChangeLookAndFeel('Dark')
66

7-
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1))
7+
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1), grab_anywhere=False)
88

99
column1 = [[sg.Text('Column 1', background_color='black', justification='center', size=(10, 1))],
1010
[sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')],

Demo_Borderless_Window.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
21
import PySimpleGUI as sg
2+
33
"""
44
Turn off padding in order to get a really tight looking layout.
55
"""
6+
67
sg.ChangeLookAndFeel('Dark')
78
sg.SetOptions(element_padding=(0, 0))
89
layout = [[sg.T('User:', pad=((3, 0), 0)), sg.OptionMenu(values=('User 1', 'User 2'), size=(20, 1)),
@@ -15,10 +16,13 @@
1516
sg.ReadFormButton('Reset', button_color=('white', '#9B0023')),
1617
sg.ReadFormButton('Submit', button_color=('gray60', 'springgreen4')),
1718
sg.SimpleButton('Exit', button_color=('white', '#00406B'))]]
19+
1820
form = sg.FlexForm("Time Tracker", default_element_size=(12, 1), text_justification='r', auto_size_text=False,
1921
auto_size_buttons=False, no_titlebar=True,
2022
default_button_element_size=(12, 1))
23+
2124
form.Layout(layout)
25+
2226
while True:
2327
button, values = form.Read()
2428
if button is None or button == 'Exit':

Demo_Font_Sizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
import PySimpleGUI as sg
66

7-
form = sg.FlexForm("Font size selector")
87

98
fontSize = 12
109

1110
layout = [[sg.Spin([sz for sz in range(6, 172)], font=('Helvetica 20'), initial_value=fontSize, change_submits=True, key='spin'),
1211
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')]]
1312

1413
sz = fontSize
14+
form = sg.FlexForm("Font size selector", grab_anywhere=False)
1515
form.Layout(layout)
1616
while True:
1717
button, values= form.Read()

Demo_Pi_Robotics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def RemoteControlExample():
1414
image_left = 'ButtonGraphics/RobotLeft.png'
1515
image_right = 'ButtonGraphics/RobotRight.png'
1616
sg.SetOptions(border_width=0, button_color=('black', back), background_color=back, element_background_color=back, text_element_background_color=back)
17-
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True)
17+
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False)
1818
status_display_elem = sg.T('', justification='center', size=(19,1))
1919
form_rows = [[sg.Text('Robotics Remote Control')],
2020
[status_display_elem],
@@ -49,7 +49,7 @@ def RemoteControlExample():
4949

5050
def RemoteControlExample_NoGraphics():
5151
# Make a form, but don't use context manager
52-
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True)
52+
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False)
5353
status_display_elem = sg.T('', justification='center', size=(19,1))
5454
form_rows = [[sg.Text('Robotics Remote Control', justification='center')],
5555
[status_display_elem],

Demo_Timer.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,31 @@
44
# form that doen't block
55
# good for applications with an loop that polls hardware
66
def Timer():
7-
sg.ChangeLookAndFeel('TealMono')
7+
sg.ChangeLookAndFeel('Dark')
88
# Make a form, but don't use context manager
9-
form = sg.FlexForm('Running Timer', auto_size_text=True)
9+
form = sg.FlexForm('Running Timer', grab_anywhere=False, no_titlebar=True, auto_size_buttons=False)
1010
# Create a text element that will be updated with status information on the GUI itself
1111
# Create the rows
1212
form_rows = [[sg.Text('Stopwatch')],
1313
[sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center', key='text')],
14-
[sg.ReadFormButton('Pause/Resume'), sg.ReadFormButton('Reset')]]
14+
[sg.ReadFormButton('Pause'), sg.ReadFormButton('Reset'), sg.Exit()]]
1515
# Layout the rows of the form and perform a read. Indicate the form is non-blocking!
16-
form.LayoutAndRead(form_rows, non_blocking=True)
17-
18-
#
19-
# Some place later in your code...
20-
# You need to perform a ReadNonBlocking on your form every now and then or
21-
# else it won't refresh.
16+
form.Layout(form_rows)
2217
#
2318
# your program's main loop
2419
i = 0
2520
paused = False
2621
while (True):
2722
# This is the code that reads and updates your window
28-
form.FindElement('text').Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
2923
button, values = form.ReadNonBlocking()
24+
form.FindElement('text').Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
3025

31-
if values is None:
26+
if values is None or button == 'Exit':
3227
break
3328

3429
if button is 'Reset':
3530
i=0
36-
elif button is 'Pause/Resume':
31+
elif button is 'Pause':
3732
paused = not paused
3833

3934
if not paused:

0 commit comments

Comments
 (0)