grab_anywhere option now available for non-blocking forms, but defaults to False for non-blocking. More Cookbook cleanup

This commit is contained in:
MikeTheWatchGuy 2018-09-08 15:32:38 -04:00
parent c9625b548b
commit 699a6912d2
2 changed files with 10 additions and 9 deletions

View File

@ -108,7 +108,7 @@ def AllWidgetsWithContext():
# sg.ChangeLookAndFeel('GreenTan')
with sg.FlexForm('Everything bagel', default_element_size=(40, 1)) as form:
with sg.FlexForm('Everything bagel', default_element_size=(40, 1), grab_anywhere=False) as form:
layout = [
[sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))],
[sg.Text('Here is some text.... and a place to enter text')],
@ -140,7 +140,7 @@ def AllWidgetsNoContext():
# Green & tan color scheme
sg.ChangeLookAndFeel('GreenTan')
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1))
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1), grab_anywhere=False)
layout = [
[sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))],
[sg.Text('Here is some text.... and a place to enter text')],
@ -274,7 +274,7 @@ def RealtimeButtons():
import PySimpleGUI as sg
# 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')
form_rows = [[sg.Text('Robotics Remote Control')],
[sg.T(' ' * 10), sg.RealtimeButton('Forward')],
@ -319,8 +319,8 @@ def TabbedForm():
"""
import PySimpleGUI as sg
with sg.FlexForm('', auto_size_text=True) as form:
with sg.FlexForm('', auto_size_text=True) as form2:
with sg.FlexForm('') as form:
with sg.FlexForm('') as form2:
layout_tab_1 = [[sg.Text('First tab', size=(20, 1), font=('helvetica', 15))],
[sg.InputText(), sg.Text('Enter some info')],
@ -352,7 +352,7 @@ def MediaPlayer():
image_exit = './ButtonGraphics/Exit.png'
# Open a form, note that context manager can't be used generally speaking for async forms
form = sg.FlexForm('Media File Player', auto_size_text=True, default_element_size=(20, 1),
form = sg.FlexForm('Media File Player', default_element_size=(20, 1),
font=("Helvetica", 25))
# define layout of the rows
layout = [[sg.Text('Media File Player', size=(17, 1), font=("Helvetica", 25))],
@ -623,7 +623,7 @@ def CanvasWidget():
[gui.T('Change circle color to:'), gui.ReadFormButton('Red'), gui.ReadFormButton('Blue')]
]
form = gui.FlexForm('Canvas test')
form = gui.FlexForm('Canvas test', grab_anywhere=True)
form.Layout(layout)
form.ReadNonBlocking()

View File

@ -1455,7 +1455,7 @@ class FlexForm:
'''
Display a user defined for and return the filled in data
'''
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size = (None, None), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True, text_justification=None, no_titlebar=False, grab_anywhere=True, keep_on_top=False):
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size = (None, None), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True, text_justification=None, no_titlebar=False, grab_anywhere=None, keep_on_top=False):
self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT
self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS
self.Title = title
@ -2700,7 +2700,8 @@ def StartupTK(my_flex_form):
my_flex_form.TKroot = root
# Make moveable window
if (my_flex_form.NoTitleBar or my_flex_form.GrabAnywhere) and not my_flex_form.NonBlocking:
if ((my_flex_form.NoTitleBar or my_flex_form.GrabAnywhere in (None, True)) and not my_flex_form.NonBlocking) or \
(my_flex_form.GrabAnywhere == True and my_flex_form.NonBlocking):
root.bind("<ButtonPress-1>", my_flex_form.StartMove)
root.bind("<ButtonRelease-1>", my_flex_form.StopMove)
root.bind("<B1-Motion>", my_flex_form.OnMotion)