简体   繁体   中英

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.

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.

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.

Works perfectly and no need for GetScrollPos since I'm pretty sure there is no 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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM