New feature - Alpha Channel for Windows

This commit is contained in:
MikeTheWatchGuy 2018-10-17 11:13:49 -04:00
parent a89d6b562d
commit ca546099f8
1 changed files with 14 additions and 3 deletions

View File

@ -2406,7 +2406,7 @@ class ErrorElement(Element):
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
class Window: 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 Window
:param title: :param title:
@ -2472,7 +2472,7 @@ class Window:
self.KeepOnTop = keep_on_top self.KeepOnTop = keep_on_top
self.ForceTopLevel = force_toplevel self.ForceTopLevel = force_toplevel
self.Resizable = resizable self.Resizable = resizable
self.AlphaChannel = 255 self._AlphaChannel = alpha_channel
# ------------------------- Add ONE Row to Form ------------------------- # # ------------------------- Add ONE Row to Form ------------------------- #
def AddRow(self, *args): def AddRow(self, *args):
@ -2779,8 +2779,19 @@ class Window:
:param alpha: From 0 to 1 with 0 being completely transparent :param alpha: From 0 to 1 with 0 being completely transparent
:return: :return:
''' '''
self._AlphaChannel = alpha
self.TKroot.attributes('-alpha', 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): def __enter__(self):
return self return self
@ -4052,7 +4063,7 @@ def StartupTK(my_flex_form):
my_flex_form.SetIcon(my_flex_form.WindowIcon) my_flex_form.SetIcon(my_flex_form.WindowIcon)
try: 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: except:
pass pass