New Windows features - Move, SetAlpha

This commit is contained in:
MikeTheWatchGuy 2018-10-16 18:36:12 -04:00
parent c121bba54b
commit 5606525486
1 changed files with 22 additions and 1 deletions

View File

@ -2430,6 +2430,7 @@ class Window:
:param no_titlebar: :param no_titlebar:
:param grab_anywhere: :param grab_anywhere:
:param keep_on_top: :param keep_on_top:
:param resizable:
''' '''
self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT 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.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS
@ -2471,6 +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
# ------------------------- Add ONE Row to Form ------------------------- # # ------------------------- Add ONE Row to Form ------------------------- #
def AddRow(self, *args): def AddRow(self, *args):
@ -2673,6 +2675,14 @@ class Window:
return screen_width, screen_height return screen_width, screen_height
def Move(self, x, y):
try:
self.TKroot.geometry("+%s+%s" % (x, y))
except:
pass
def StartMove(self, event): def StartMove(self, event):
try: try:
self.TKroot.x = event.x self.TKroot.x = event.x
@ -2761,6 +2771,14 @@ class Window:
def Reappear(self): def Reappear(self):
self.TKroot.attributes('-alpha', 255) self.TKroot.attributes('-alpha', 255)
def SetAlpha(self, alpha):
'''
Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return:
'''
self.TKroot.attributes('-alpha', alpha)
def __enter__(self): def __enter__(self):
return self return self
@ -3354,8 +3372,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth, font=font) tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth, font=font)
tkbutton.bind('<ButtonRelease-1>', element.ButtonReleaseCallBack) tkbutton.bind('<ButtonRelease-1>', element.ButtonReleaseCallBack)
tkbutton.bind('<ButtonPress-1>', element.ButtonPressCallBack) tkbutton.bind('<ButtonPress-1>', element.ButtonPressCallBack)
if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT: if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT and bc[1] != COLOR_SYSTEM_DEFAULT:
tkbutton.config(foreground=bc[0], background=bc[1], activebackground=bc[1]) tkbutton.config(foreground=bc[0], background=bc[1], activebackground=bc[1])
elif bc[1] == COLOR_SYSTEM_DEFAULT:
tkbutton.config(foreground=bc[0])
element.TKButton = tkbutton # not used yet but save the TK button in case element.TKButton = tkbutton # not used yet but save the TK button in case
wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels
if element.ImageFilename: # if button has an image on it if element.ImageFilename: # if button has an image on it