您的位置:首页 > 编程语言 > Python开发

wxpython学习6

2015-11-21 01:56 633 查看

import wx

class 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()
普通按钮与位图按钮


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: