wxpython学习6

来源:互联网 发布:网络销售沟通技巧 编辑:程序博客网 时间:2024/06/05 14:52
import wxclass ButtonFrame(wx.Frame):    def __init__(self):        wx.Frame.__init__(self, None, -1, u'按钮', size=(300, 200))        panel = wx.Panel(self, -1)        self.button = wx.Button(panel, -1, u'确定', pos=(10, 10))        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)        self.button.SetDefault()  # 普通按钮        self.inputText = wx.TextCtrl(panel, -1, "", pos=(100, 10), size=(150, -1), style=wx.TE_READONLY)        bmp = wx.Image("CloseNormal.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()        self.button2 = wx.BitmapButton(panel, -1, bmp, pos=(20, 100), size=(120, 60))        self.Bind(wx.EVT_BUTTON, self.OnClick2, self.button2)        self.button2.SetDefault()  # 位图按钮    def OnClick(self, event):        self.inputText.Value = "hello world"    def OnClick2(self, event):        self.inputText.Value = "hello world2"if __name__ == '__main__':    app = wx.PySimpleApp()    frame = ButtonFrame()    frame.Show()

app.MainLoop()

普通按钮与位图按钮

                                             
0 0