5 wx
.Frame
.__init
__(self
, None, title
="Am I transparent?")
10 self
.st
= wx
.StaticText(p
, -1, str(self
.amount
), (25,25))
11 self
.st
.SetFont(wx
.Font(18, wx
.SWISS
, wx
.NORMAL
, wx
.NORMAL
))
13 self
.timer
= wx
.Timer(self
)
15 self
.Bind(wx
.EVT_TIMER
, self
.AlphaCycle
)
17 self
.Bind(wx
.EVT_CLOSE
, self
.OnCloseWindow
)
20 def OnCloseWindow(self
, evt
):
26 def AlphaCycle(self
, evt
):
27 self
.amount
+= self
.delta
28 if self
.amount
== 0 or self
.amount
== 255:
29 self
.delta
= -self
.delta
30 self
.st
.SetLabel(str(self
.amount
))
32 # Note that we no longer need to use ctypes or win32api to
33 # make transparent windows, however I'm not removing the
34 # MakeTransparent code from this sample as it may be helpful
35 # for somebody someday.
36 #self.MakeTransparent(self.amount)
38 # Instead we'll just call the SetTransparent method
39 self
.SetTransparent(self
.amount
)
42 def MakeTransparent(self
, amount
):
43 hwnd
= self
.GetHandle()
46 _winlib
= ctypes
.windll
.user32
47 style
= _winlib
.GetWindowLongA(hwnd
, 0xffffffecL
)
49 _winlib
.SetWindowLongA(hwnd
, 0xffffffecL
, style
)
50 _winlib
.SetLayeredWindowAttributes(hwnd
, 0, amount
, 2)
53 import win32api
, win32con
, winxpgui
54 _winlib
= win32api
.LoadLibrary("user32")
55 pSetLayeredWindowAttributes
= win32api
.GetProcAddress(
56 _winlib
, "SetLayeredWindowAttributes")
57 if pSetLayeredWindowAttributes
== None:
59 exstyle
= win32api
.GetWindowLong(hwnd
, win32con
.GWL_EXSTYLE
)
60 if 0 == (exstyle
& 0x80000):
61 win32api
.SetWindowLong(hwnd
,
64 winxpgui
.SetLayeredWindowAttributes(hwnd
, 0, amount
, 2)