question about wxpython CtrlList event binder: wx.EVT_LIST_ITEM_RIGHT_CLICK
kent.yuan at gmail.com
Tue Apr 21 23:59:18 CEST 2009
thx for the wxpython maillist link, I will give it a shot. But I would
like to paste the code snippet here as well, hope it can tell
sufficient information. (I added some comments in the class. ) Thank
Tag list ListCtrl widget
# this 'images' is not important, just icons
images = (myGui.ICON_TAG_CUSTOM,
# so the listctrl is in REPORT MODE
#here are some property value init..
self.parent = parent
self.mainFrm = self.GetTopLevelParent() # main Frame
il = wx.ImageList(24,24)
for image in images:
self.popmenu = None
# bind the events
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect) #selected,
e.g. left click
# right click, HERE COMES THE PROBLEM
#this function load the item data into the List
#this is the function
tagId = event.GetData()
# following codes are omitted. just some business logic stuff.
checking the tagId, making decision of showing popup menu items...
On Apr 21, 11:24 pm, Mike Driscoll <kyoso... at gmail.com> wrote:
> On Apr 21, 3:35 pm, Kent <kent.y... at gmail.com> wrote:
> > Hi there,
> > I wrote a desktop application with wxPython2.8. And got a problem.
> > Hope here someone can give some hint. Thanks in advance.
> I recommend joining the wxPython mailing list and posting there. The
> guys there are great and can probably help you out. Seehttp://wxpython.org/maillist.php
> > There was a ListCtrl (lc) in my GUI, and it was a bit long, so that
> > there would be some blank space below ("empty area") in case there
> > were only a few items.
> > I bind a function on the event wx.EVT_LIST_ITEM_RIGHT_CLICK, when user
> > rightclick on the lc item, my function was triggered, and open a popup
> > menu.
> > Depends on the item user clicked, the menu items can be different. I
> > checked the event.getData(), to decide which menu item will show to
> > user. That is, if user right click on the "empty area", the
> > event.getData() will be 0. I wrote the appl. under Linux, and tested,
> > it worked as what I expected.
> > However, today someone reported a bug, said, under Windows XP, right
> > clicking on the items of lc, it works fine, but if on the "empty area"
> > of the lc, nothing happened, no popup menu. I tested under WINXP, the
> > function was not triggered at all when I right-clicked on the "empty
> > area".
> > I tried to bind wx.EVT_RIGHT_DOWN(UP) to the lc, but the function
> > cannot be triggered under Linux. any suggestion?
> > Thanks
> > regards,
> > Kent
> If you join the wxPython list, they'll probably ask for a small
> runnable sample. Here's some instructions for how to do that:http://wiki.wxpython.org/MakingSampleApps
> It would be good to know what mode you are using for your ListCtrl.
> List view, report, icon or what? The demo doesn't have any white space
> at the end, so I can't test this easily. Are you using a sizer to hold
> the widget?
> - Mike
More information about the Python-list