[wxPython-users] EditableListBox buttons
Robin Dunn
robin at alldunn.com
Fri Mar 7 18:16:09 PST 2008
L. Fanchi wrote:
> I'm trying to get the sort and delete buttons to work, but I'm also
> having problems with those.
> Here's what I did:
>
> imageList = gizmos.EditableListBox(panel, -1, "Images", pos =
> (300,80), size = (250, 330), style = wx.gizmos.EL_ALLOW_DELETE)
> imageList.SetStrings([])
> imageList_w = imageList.GetListCtrl()
> imageList_delbutton = imageList.GetDelButton()
> imageList_delbutton.Enable(True)
> self.Bind(wx.EVT_BUTTON, self.OnDeleteItem, imageList_delbutton)
> wx.EVT_LIST_ITEM_SELECTED(imageList, imageList_w.GetId(),
> self.OnItemSelected)
>
> The event for the selection of the item triggers the
> self.OnItemSelected, but the delete button, for some reason, doesn't
> trigger the self.OnDeleteItem at this point..
Because the EditableListBox is catching the EVT_BUTTON for the delete
button, and not calling Skip, and because of how you bound the event the
other event handler is called first, (so because it is not calling Skip
it stops looking for handlers.) If you want your handler called first
then bind it like this instead:
self.imageList_delbutton.Bind(wx.EVT_BUTTON, self.OnDeleteItem)
For more info about this see:
http://wiki.wxpython.org/self.Bind_vs._self.button.Bind
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list