一个简单的界面,使用wxpython

时间:2022-02-06 07:16:00
import wx
app=wx.App()
win=wx.Frame(None,title="jisuanqi")
bkg=wx.Panel(win)

screen=wx.TextCtrl(bkg)

btn7=wx.Button(bkg,label="7")
btn8=wx.Button(bkg,label="8")
btn9=wx.Button(bkg,label="9")
btn4=wx.Button(bkg,label="4")
btn5=wx.Button(bkg,label="5")
btn6=wx.Button(bkg,label="6")
btn1=wx.Button(bkg,label="1")
btn2=wx.Button(bkg,label="2")
btn3=wx.Button(bkg,label="3")

box1=wx.BoxSizer()
box2=wx.BoxSizer()
box3=wx.BoxSizer()
box4=wx.BoxSizer()
box=wx.BoxSizer(wx.VERTICAL)

box1.Add(screen,proportion=1,flag=wx.EXPAND)
box2.Add(btn7,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box2.Add(btn8,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box2.Add(btn9,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box3.Add(btn4,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box3.Add(btn5,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box3.Add(btn6,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box4.Add(btn1,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box4.Add(btn2,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)
box4.Add(btn3,proportion=1,flag=wx.EXPAND|wx.ALL,border=3)

box.Add(box1,proportion=1,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=1)
box.Add(box2,proportion=1,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=1)
box.Add(box3,proportion=1,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=1)
box.Add(box4,proportion=1,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=1)

bkg.SetSizer(box)
win.Show()
app.MainLoop()
一个简单的界面,使用wxpython