wx.TreeCtrl.GetSelections() not working as expected
Edgar Poth
epmlist at googlemail.com
Fri Jun 1 05:48:33 PDT 2007
Hi,
The number of tree items returned by GetSelections() is not correct in all
situations. When selecting multiple items (holding shift key down)
then GetSelections() is not returning all selected items. If you select n
items,
the returned list from GetSelections() is n-1 items long. The missing item
is not
the first or last item in the tree. It is item n-1 which is missing !!
Example: If I select "item1, item2, item3, item4" then GetSelections() will
return "item1, item2, item4"
When deselecting tree items, everything is OK.
Sorry if the above is a bit unclear..
The reproduce the problem you can modify the TreeCtrl-DEMO by:
- Adding the wx.TR_MULTIPLE style to the TreeCtrl
self.tree =3D MyTreeCtrl(self, tID, wx.DefaultPosition, wx.DefaultSize,
wx.TR_HAS_BUTTONS
| wx.TR_EDIT_LABELS
| wx.TR_MULTIPLE
#| wx.TR_HIDE_ROOT
, self.log)
- Modify the OnSelChange method
def OnSelChanged(self, event):
self.item =3D event.GetItem()
if self.item:
self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(
self.item))
if wx.Platform =3D=3D '__WXMSW__':
self.log.WriteText("BoundingRect: %s\n" %
self.tree.GetBoundingRect(self.item,
True))
items =3D self.tree.GetSelections()
self.log.WriteText(str(map(self.tree.GetItemText, items)))
event.Skip()
- Run the DEMO and compare the seleted tree items with the items returned
by self.tree.GetSelections()
System: Windows XP, Python 2.5 , wxPython 2.8.1.1
Can somebody confirm this problem ?
Thanks.
Edgar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200706=
01/755a987d/attachment.htm
More information about the wxpython-users
mailing list