我希望当一个新项目被添加到列表中,并且ScrollBar变得更长时,my wx.ListCtrl的ScrollBar会自动下降。我就是这样创建一个wx.ListCtrl的
import wx
app = wx.App()
frame = wx.Frame(None, -1, title='2', pos=(0, 0), size=(500, 500))
frame.Show(True)
app.SetTopWindow(frame)
message_list = wx.ListCtrl(frame, size=(200, 200), pos=(0, 0),
style=wx.LC_REPORT | wx.BORDER_SUNKEN)
message_list.InsertColumn(0, 'Chat: ', width=150)
for i in range(15):
message_list.InsertItem(i, "name" + str(i))
### I want that after this loop, the scroll bar will be at the end of the list (Name 14)
app.MainLoop()发布于 2020-01-11 15:42:36
选择(self,idx,on=1)
选择/取消选择项。
& EnsureVisible(n)确保所选项是可见的,即它滚动列表控件。
所以这是可行的:
import wx
app = wx.App()
frame = wx.Frame(None, -1, title='2', pos=(0, 0), size=(500, 500))
frame.Show(True)
app.SetTopWindow(frame)
message_list = wx.ListCtrl(frame, size=(200, 200), pos=(0, 0),
style=wx.LC_REPORT | wx.BORDER_SUNKEN)
message_list.InsertColumn(0, 'Chat: ', width=150)
for i in range(30):
message_list.InsertItem(i, "name" + str(i))
msg_endpoint = message_list.GetItemCount() - 1
message_list.Select(msg_endpoint,1) #Select last item
message_list.EnsureVisible(msg_endpoint)
### I want that after this loop, the scroll bar will be at the end of the list (Name 14)
app.MainLoop()注意:使用message_list.Select(i,0)取消选择项目(I)
只有在需要时才会看到滚动条。

https://stackoverflow.com/questions/59695022
复制相似问题