diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 5e9d3a52..9e7beb19 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -2406,7 +2406,7 @@ class ErrorElement(Element): # ------------------------------------------------------------------------- # class Window: - 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, 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, resizable=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, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, force_toplevel = False, alpha_channel=1, return_keyboard_events=False, use_default_focus=True, text_justification=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=False): ''' Window :param title: @@ -2472,7 +2472,7 @@ class Window: self.KeepOnTop = keep_on_top self.ForceTopLevel = force_toplevel self.Resizable = resizable - self.AlphaChannel = 255 + self._AlphaChannel = alpha_channel # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -2779,8 +2779,19 @@ class Window: :param alpha: From 0 to 1 with 0 being completely transparent :return: ''' + self._AlphaChannel = alpha self.TKroot.attributes('-alpha', alpha) + @property + def AlphaChannel(self): + return self._AlphaChannel + + @AlphaChannel.setter + def AlphaChannel(self, alpha): + self._AlphaChannel = alpha + self.TKroot.attributes('-alpha', alpha) + + def __enter__(self): return self @@ -4052,7 +4063,7 @@ def StartupTK(my_flex_form): my_flex_form.SetIcon(my_flex_form.WindowIcon) try: - root.attributes('-alpha', 255) # hide window while building it. makes for smoother 'paint' + root.attributes('-alpha', my_flex_form.AlphaChannel) # Make window visible again except: pass