diff --git a/Demo_All_Widgets.py b/Demo_All_Widgets.py index cb03220f..15d81ce3 100644 --- a/Demo_All_Widgets.py +++ b/Demo_All_Widgets.py @@ -4,7 +4,7 @@ import PySimpleGUI as sg def Everything(): 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))], [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], diff --git a/Demo_Borderless_Window.py b/Demo_Borderless_Window.py index 51e1663f..1d615059 100644 --- a/Demo_Borderless_Window.py +++ b/Demo_Borderless_Window.py @@ -1,8 +1,9 @@ - import PySimpleGUI as sg + """ Turn off padding in order to get a really tight looking layout. """ + sg.ChangeLookAndFeel('Dark') sg.SetOptions(element_padding=(0, 0)) 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('Submit', button_color=('gray60', 'springgreen4')), sg.SimpleButton('Exit', button_color=('white', '#00406B'))]] + form = sg.FlexForm("Time Tracker", default_element_size=(12, 1), text_justification='r', auto_size_text=False, auto_size_buttons=False, no_titlebar=True, default_button_element_size=(12, 1)) + form.Layout(layout) + while True: button, values = form.Read() if button is None or button == 'Exit': diff --git a/Demo_Font_Sizer.py b/Demo_Font_Sizer.py index 40878f2f..bcc53e55 100644 --- a/Demo_Font_Sizer.py +++ b/Demo_Font_Sizer.py @@ -4,7 +4,6 @@ import PySimpleGUI as sg -form = sg.FlexForm("Font size selector") 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')]] sz = fontSize +form = sg.FlexForm("Font size selector", grab_anywhere=False) form.Layout(layout) while True: button, values= form.Read() diff --git a/Demo_Pi_Robotics.py b/Demo_Pi_Robotics.py index 8debc1cb..23c7c501 100644 --- a/Demo_Pi_Robotics.py +++ b/Demo_Pi_Robotics.py @@ -14,7 +14,7 @@ def RemoteControlExample(): image_left = 'ButtonGraphics/RobotLeft.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) - 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)) form_rows = [[sg.Text('Robotics Remote Control')], [status_display_elem], @@ -49,7 +49,7 @@ def RemoteControlExample(): def RemoteControlExample_NoGraphics(): # 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)) form_rows = [[sg.Text('Robotics Remote Control', justification='center')], [status_display_elem], diff --git a/Demo_Timer.py b/Demo_Timer.py index 9031af18..1f76d1e5 100644 --- a/Demo_Timer.py +++ b/Demo_Timer.py @@ -4,36 +4,31 @@ import time # form that doen't block # good for applications with an loop that polls hardware def Timer(): - sg.ChangeLookAndFeel('TealMono') + sg.ChangeLookAndFeel('Dark') # 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 the rows form_rows = [[sg.Text('Stopwatch')], [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! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # 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. + form.Layout(form_rows) # # your program's main loop i = 0 paused = False while (True): # 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() + 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 if button is 'Reset': i=0 - elif button is 'Pause/Resume': + elif button is 'Pause': paused = not paused if not paused: