1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| import wx
class MyFrame(wx.Frame): def __init__(self): super().__init__(parent=None,title="第一个窗体程序!",size=(1000,600)) self.Center() sizer1 = wx.BoxSizer() sizer2 = wx.BoxSizer(wx.VERTICAL) sizer3 = wx.BoxSizer() text = wx.StaticText(self,-1,u'这是一个文本信息',size=(200,100),style=wx.ALIGN_CENTER) font = wx.Font(15,wx.FONTFAMILY_MODERN,wx.NORMAL,wx.NORMAL) text.SetFont(font)
sizer1.Add(text,0,wx.ALL,50)
imput_kuang = wx.TextCtrl(self,-1,value="请输入文本内容",size=(200,100),style=wx.TE_MULTILINE) sizer1.Add(imput_kuang,0,wx.ALL,50) show_kuang = wx.TextCtrl(self,-1,value="显示的内容",size=(300,200),style=wx.TE_MULTILINE) sizer1.Add(show_kuang,0,wx.ALL,50)
button = wx.Button(self,-1,label="点我",size=(100,50)) sizer2.Add(button,0)
xaila_kuang = wx.ComboBox(self,-1,value="下拉框",size=(200,50),choices=['1','2','3'],style=wx.CB_READONLY) sizer2.Add(xaila_kuang,0,wx.Top|wx.LEFT,10)
danxuan_kuang = wx.RadioBox(self,-1,label="单选框",size=(50,100),choices=['1','2','3']) sizer2.Add(danxuan_kuang,0,wx.ALL,50)
fuxuan1_kuang = wx.CheckBox(self,-1,label="复选框1",size=(30,100)) fuxuan2_kuang = wx.CheckBox(self,-1,label="复选框2",size=(30,100)) fuxuan3_kuang = wx.CheckBox(self,-1,label="复选框3",size=(30,100)) sizer2.Add(fuxuan1_kuang,0,wx.RIGHT,10) sizer2.Add(fuxuan2_kuang,0,wx.RIGHT,10) sizer2.Add(fuxuan3_kuang,0,wx.RIGHT,10)
sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(sizer1) sizer.Add(sizer2) sizer.Add(sizer3) self.SetSizer(sizer)
StatusBar = wx.StatusBar(self,-1) StatusBar.SetFieldsCount(3) StatusBar.SetStatusWidths([-1,-1,-1]) StatusBar.SetStatusText('About',0) StatusBar.SetStatusText('状态栏',2) self.SetStatusBar(StatusBar)
menuber_box = wx.MenuBar() filemenuber = wx.Menu() ewitem1 = wx.MenuItem(filemenuber,-1,'菜单选项-1') ewitem2 = wx.MenuItem(filemenuber,-1,'菜单选项-2') filemenuber.Append(ewitem1) filemenuber.Append(ewitem2) menuber_box.Append(filemenuber,'菜单') self.SetMenuBar(menuber_box)
class App(wx.App): def OnInit(self): myFrame=MyFrame() myFrame.Show() return True
def OnExit(self): print('应用程序退出') return True if __name__ =="__main__": app=App() app.MainLoop()
|