我想限制列表控件框的大小。让我们看看下面的代码:限制wxpython中wxListCtrl的大小
import wx
class Students(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(380, 230))
hbox = wx.BoxSizer(wx.HORIZONTAL)
panel = wx.Panel(self, -1)
self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT)
self.list.InsertColumn(0, 'name')
self.list.InsertColumn(1, 'age')
hbox.Add(self.list, 1,wx.EXPAND)
panel.SetSizer(hbox)
self.Centre()
self.Show(True)
app = wx.App()
Students(None, -1, 'studs')
app.MainLoop()
如果我让水平框定径机的比例= 0,这样的:
hbox.Add(self.list, 0,wx.EXPAND)
则存在不同的问题。比例= 1的问题是,在“年龄”列之后,列表控制框为第三列不存在而存在大量空白空间。 比例= 0的问题是它的宽度太短。 我想仅显示带有“名称”和“年龄”列的列表控制框,并保存剩余的空间。我怎么做?