[英]wxPython: Items in BoxSizer don't expand horizontally, only vertically
[英]wxpython - Expand list control vertically not horizontally
我有一个ListCtrl,它显示项目列表供用户选择。 除ctrl不足以显示所有项目外,我希望它使用垂直scoll栏向下扩展,而不是使用水平滚动条(向右扩展)向下扩展。
ListCtrl的创建:
self.subjectList = wx.ListCtrl(self, self.ID_SUBJECT, style = wx.LC_LIST | wx.LC_SINGLE_SEL | wx.LC_VRULES)
使用wx.ListItem插入项目:
item = wx.ListItem()
item.SetText(subject)
item.SetData(id)
item.SetWidth(200)
self.subjectList.InsertItem(item)
使用wxLC_REPORT样式。
import wx
class Test(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
self.test = wx.ListCtrl(self, style = wx.LC_REPORT | wx.LC_NO_HEADER)
for i in range(5):
self.test.InsertColumn(i, 'Col %d' % (i + 1))
self.test.SetColumnWidth(i, 200)
for i in range(0, 100, 5):
index = self.test.InsertStringItem(self.test.GetItemCount(), "")
for j in range(5):
self.test.SetStringItem(index, j, str(i+j)*30)
self.Show()
app = wx.PySimpleApp()
app.TopWindow = Test()
app.MainLoop()
尝试这个:
import wx
class Test(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
self.test = wx.ListCtrl(self, style = wx.LC_ICON | wx.LC_AUTOARRANGE)
for i in range(100):
self.test.InsertStringItem(self.test.GetItemCount(), str(i))
self.Show()
app = wx.PySimpleApp()
app.TopWindow = Test()
app.MainLoop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.