def set_alpha(self, alpha=100, colorkey=0, mask=False):
""" Sets the transparency of the window. """
if self.alpha != None:
if not self._transparency:
style = win32gui.GetWindowLong(self._hwnd, GWL_EXSTYLE)
if (style & WS_EX_LAYERED) != WS_EX_LAYERED:
style = style | WS_EX_LAYERED
win32gui.SetWindowLong(self._hwnd, GWL_EXSTYLE, style)
self._transparency = True
if mask and colorkey:
flags = LWA_COLORKEY
else:
flags = LWA_ALPHA
if colorkey:
flags = flags | LWA_COLORKEY
win_alpha = int(float(alpha)/100*255)
winxpgui.SetLayeredWindowAttributes(self._hwnd, colorkey,
win_alpha, flags)
self.alpha = int(alpha)
评论列表
文章目录