wxpython listbox multiselection

来源:互联网 发布:摆摊打印照片软件 编辑:程序博客网 时间:2024/06/14 08:25
If you need the selection events when more 
than one item is selected, then you'll want to not use virtual mode.  If 
you just need to be able to find out what items are currently selected 
then you can use a loop like this: 

        item = listctrl.GetFirstSelected() 
        while item != -1: 
                # do something with the item 

                item = listctrl.GetNextSelected(item) 


When the ListCtrl is in virtual mode then it won't do anything that 
could possibly mean that every item in the list would be visited.  This 
includes sending an event for every item selected when a multiple 
selection is done.  To understand why this is the case try to imagine 
what would happen if you had an event handler for item selection and a 
virtual listctrl with 1 billion items, and you click the first item, 
scroll to the bottom and shift-click the last item.  Scrolling would be 
quick because it only needs to visit those items that need to be 
painted, but sending the selection events would take a week or so.  ;-) 

-- 
Robin Dunn 
Software Craftsman 



http://wxpython-users.1045709.n5.nabble.com/listctrl-and-multiple-selection-td2355984.html

0 0