Button1是一个没有背景的png,但它显示为灰色背景,我尝试将其设置为透明,但这只是给它一个黑色背景。
如何使按钮背景透明?
import wx
class windowClass(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, None, -1, 'test', size=(1000, 600))
display_size = wx.DisplaySize()
print display_size
path = "background.png"
bg = wx.Image(path, wx.BITMAP_TYPE_ANY)
bg = bg.Scale(display_size[0],display_size[1]).ConvertToBitmap()
self.back = wx.StaticBitmap(self, -1, bg, pos=(0,0))
path1 = wx.Image("button.png")
path1.Rescale(100, 100)
image1 = wx.BitmapFromImage(path1)
self.button1 = wx.StaticBitmap(self.back, -1, image1, (10, 10))
self.button1.Bind(wx.EVT_LEFT_DOWN, self.button1Click)
self.button1.SetBackgroundColour(wx.TransparentColour)
self.Show()
def button1Click(self,event):
self.Close()
def main():
app = wx.App()
windowClass(None)
app.MainLoop()
main()