1
我試圖調整控件的大小時遇到問題,有人能指出需要修正整齊控件堆棧的位置嗎?Python:wxPython:關於GridBagSizer佈局管理的幫助
即TextCtrl框應該是標準的默認尺寸。
and The閱讀&將按鈕設置在TextCtrl框正下方。
這裏是我的代碼:
class AVMCPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
#create the grouping box and sizer for the outline
self.box = wx.StaticBox(self, -1, "AVMC CONTROL PANEL")
self.bsizer = wx.StaticBoxSizer(self.box, wx.VERTICAL)
#create the sizer and place controls within box
self.gbs = wx.GridBagSizer(5,5)
self.sampleList = ['zero', 'one', 'two', 'three', 'four'] #temp list items
self.t1 = wx.StaticText(self, label="Power Rail to margin:")
self.lb1 = wx.ListBox(self, 1, (100, 50), (150, 120), self.sampleList, wx.LB_SINGLE)
self.t2 = wx.StaticText(self, label="Read Voltage:")
self.t3 = wx.StaticText(self, label="Set Voltage:")
self.read_btn = wx.Button(self, 1, " Read ", (-1,-1))
self.set_btn = wx.Button(self, 1, " Set ", (-1,-1))
self.rtext = wx.TextCtrl(self, 1, "", size=(80, -1), style=wx.ALL)
self.stext = wx.TextCtrl(self, 1, "", size=(80, -1), style=wx.ALL)
self.gbs.Add(self.t1, (0,0))
self.gbs.Add(self.lb1, (1,0))
self.gbs.Add(self.t2, (0,5))
self.gbs.Add(self.t3, (0,10))
self.gbs.Add(self.read_btn, (2,5))
self.gbs.Add(self.set_btn, (2,10))
self.gbs.Add(self.rtext, (1,5))
self.gbs.Add(self.stext, (1,10))
#Place the control inside group box
self.bsizer.Add(self.gbs, 0, flag=wx.ALL, border=5)
#Place the static group box sizer within the border frame
#Creating a border that the static box will sit inside
self.border = wx.BoxSizer()
self.border.Add(self.bsizer, 1000, wx.ALL, 10)
self.SetSizer(self.border)
感謝。