def MakeTransparent(self, amount):
if os.name == 'nt': # could substitute: sys.platform == 'win32'
hwnd = self.GetHandle()
_winlib = win32api.LoadLibrary("user32")
pSetLayeredWindowAttributes = win32api.GetProcAddress(
_winlib, "SetLayeredWindowAttributes")
if pSetLayeredWindowAttributes is None:
return
exstyle = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
if 0 == (exstyle & 0x80000):
exstyle |= win32con.WS_EX_LAYERED | win32con.WS_EX_TOOLWINDOW | win32con.WS_EX_TRANSPARENT
win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exstyle)
win32gui.SetLayeredWindowAttributes(hwnd, 0, amount, 2)
else:
print('#### OS Platform must be MS Windows')
self.Destroy()
评论列表
文章目录