[英]Python wx.listctrl scroll position
I am trying to get a list scrolled at the initial point after an action whose result is the removal of all items and repopulation. 我试图在一个动作后的初始点滚动一个列表,其结果是删除所有项目和重新填充。
I wanted to get the scroll position recorded and then set back to it but GetScrollPos
always returns 0 for some reason. 我想记录滚动位置,然后重新设置它,但
GetScrollPos
总是因某种原因返回0。
I have been looking over all the ListCtrl
methods but can't seem to find a way and also noticed GetScrollPos
is not there but neither does it raise an exception. 我一直在查看所有的
ListCtrl
方法,但似乎找不到方法,也注意到GetScrollPos
不在那里,但它也没有引发异常。
I got it to work by calculating the bottom item and using EnsureVisible
on the one above it since EnsureVisible
always shows an extra item underneath the targeted one if there is any. 我通过计算底部项目并使用上面的项目上的
EnsureVisible
来实现它,因为如果有的话, EnsureVisible
总是会在目标项目下面显示一个额外的项目。
Works perfectly and no need for GetScrollPos
since I'm pretty sure there is no SetScrollPos
. 完美的工作,不需要
GetScrollPos
因为我很确定没有SetScrollPos
。
list_total = list.GetItemCount()
list_top = list.GetTopItem()
list_pp = list.GetCountPerPage()
list_bottom = min(list_top + list_pp, list_total - 1)
list.EnsureVisible((list_bottom - 1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.