Merge pull request #497 from MikeTheWatchGuy/Dev-latest

New feature - Alpha Channel for Windows
This commit is contained in:
MikeTheWatchGuy 2018-10-17 11:14:23 -04:00 committed by GitHub
commit fced0e40bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -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