(wxPython) Double left clicking and right clicking with ListBoxes

Vivienne velzev at freemail.nl
Tue Jun 15 13:43:49 CEST 1999


Hi there,

I've gotten into some trouble over making a selection in a listbox with a
double-left click or a right-click. It doesn't work. At first I used the
available EVT_LISTBOX_DCLICK(id, function). The problem here is that it
forgets the selection that I made, and with event.GetSelection() always
gives the index of the first item (i.e. 0). So I thought, OK, let's try it
with EVT_COMMAND_LEFT_DCLICK(id, function). But now my application doesn't
even respond to the fact that I'm double-clicking.
The problem with right-clicking is twofold :
1. There is no available method for right-clicking in a listbox (that I
could find)
2. The use of EVT_COMMAND_RIGHT_CLICK(id, function) gives the same result as
EVT_COMMAND_LEFT_DCLICK(id, function)

Could anyone please tell me how to use double-left clicking and right
clicking in listboxes (or wxPython in general)?
Thanks alot,

Vivienne
PS. I use Python 1.5.2 and wxPython 2_0b9. Here is the code I've written
that doesn't work:

def InitializeBox(self, ID, StartPoint, BoxSize):
          self.box = wxListBox(panel, ID, StartPoint, BoxSize,
self.namenlijst, wxLB_SINGLE|wxLB_SORT)
          EVT_LISTBOX(panel,ID,self.OnLeftClick)
          EVT_COMMAND_LEFT_DCLICK(panel,ID,self.OnDLeftClick)
          EVT_COMMAND_RIGHT_CLICK(panel, ID, self.OnRightClick)

def OnDLeftClick(self, event):
          p = event.GetSelection()
          print p







More information about the Python-list mailing list