注册 登录
编程论坛 Python论坛

wxpython 中怎么显示位图的按钮~~~书上的例子是错的~求救????

qq609470156 发布于 2012-10-26 09:09, 1494 次点击
class BitmapButtonFrame(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, -1, ’Bitmap Button Example’,size=(200, 150))
            panel = wx.Panel(self, -1)
            bmp = wx.Image(“bitmap.bmp”, wx.BITMAP_TYPE_BMP).ConvertToBitmap() #这里出错了~~~
            
            self.button = wx.BitmapButton(panel, -1, bmp, pos=(10, 20))
            self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
            self.button.SetDefault()
            self.button2 = wx.BitmapButton(panel, -1, bmp, pos=(100, 20),style=0)
            self.Bind(wx.EVT_BUTTON, self.OnClick, self.button2)

该怎么做才能 在按钮上显示位图呢????
2 回复
#2
qq6094701562012-10-29 09:02
换一下 wx.Image('path',wx.BTMAP_YYPE_ANY) 就行了~
主要问题是系统没有这bitmap.bmp的图片~~~自己弄一张就可以了~
#3
快乐出发02202012-10-29 12:45
一楼正解。。。。。。。
1