使用 wxpython 中的
我尝试使用
假设我想为panel1设置透明度。
SetTransparent(val)
函数可以使整个框架透明。但是,我能否使其中的一个面板变透明?我尝试使用
panelobj.SetTransparent(val)
,但没有效果。import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title,size=(250, 250))
topPanel = wx.Panel(self)
panel1 = wx.Panel(topPanel, -1)
panel1.SetTransparent(100)
panel2 = wx.Panel(topPanel, -1)
panel2.SetBackgroundColour('gray')
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(panel1,1,flag = wx.EXPAND|wx.ALL)
sizer.Add(panel2,1,flag = wx.EXPAND|wx.ALL)
topPanel.SetSizer(sizer)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'frame')
frame.Show(True)
return True
app = MyApp(0)
app.MainLoop()
假设我想为panel1设置透明度。
panel1.CanSetTransparent()
返回什么? - abarnert