gpt4 book ai didi

python - wxpython - 垂直扩展列表控件而不是水平扩展

转载 作者:太空宇宙 更新时间:2023-11-03 23:51:08 25 4
gpt4 key购买 nike

我有一个 ListCtrl,它显示一个项目列表供用户选择。这工作正常,除了当 ctrl 不够大以显示所有项目时,我希望它使用垂直滚动条向下扩展而不是使用水平滚动条,因为它向右扩展。

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()

关于python - wxpython - 垂直扩展列表控件而不是水平扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/215132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com