From 78c31358becdfaabf1bdf1d383faa3e45a34e561 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 27 Sep 2018 01:17:09 -0400 Subject: [PATCH] New Window option - Force top level - forces the window to be a Toplevel tkinter window --- PySimpleGUI.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 657799f6..4aff4c03 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -2013,7 +2013,7 @@ class Window: ''' 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, 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=False, 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, 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, force_toplevel = False, return_keyboard_events=False, use_default_focus=True, text_justification=None, no_titlebar=False, grab_anywhere=False, 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 @@ -2054,6 +2054,7 @@ class Window: self.NoTitleBar = no_titlebar self.GrabAnywhere = grab_anywhere self.KeepOnTop = keep_on_top + self.ForceTopLevel = force_toplevel # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -3471,8 +3472,13 @@ def StartupTK(my_flex_form): global _my_windows ow = _my_windows.NumOpenWindows + # print('Starting TK open Windows = {}'.format(ow)) - root = tk.Tk() if not ow else tk.Toplevel() + if not ow and not my_flex_form.ForceTopLevel: + root = tk.Tk() + else: + root = tk.Toplevel() + try: root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint' except: