Reputation: 53051
I'm trying to get a windows transparency in wxPython. I tried self.GetTransparent(), however that apparently doesn't exist. So, how do I go about getting a windows transparency?
Upvotes: 1
Views: 926
Reputation: 9451
You have to derive your own class, which will be aware of its own transparency:
import wx
class TransparentAwareFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.transparency = 255
def SetTransparent(self, value):
self.transparency = value
wx.Frame.SetTransparent(self, value)
def GetTransparent(self):
return self.transparency
class MainWindow(TransparentAwareFrame):
def __init__(self, *args, **kwargs):
TransparentAwareFrame.__init__(self, *args, **kwargs)
self.button = wx.Button(self, label="Click me!")
self.Show()
self.button.Bind(wx.EVT_BUTTON, self.onButton)
def onButton(self, e):
self.SetTransparent(self.GetTransparent() - 20)
app = wx.App(False)
win = MainWindow(None)
app.MainLoop()
Upvotes: 2