Which version of wxPython are you using? I reported a problem I have using
ver 2.2.5 (with Python 2.0) where it takes a double-right-click (rather than
single right-click) to get the menu to appear. I don't remember which
version the fix was going to be in, though.
You may also want to consider catching the event on RIGHT_UP rather than
RIGHT_DOWN. Using RIGHT_UP allows the user to change their mind, move the
mouse away, and not have a menu pop up every time they click in the tree.
-Ron
···
-----Original Message-----
From: Gareth Walters [mailto:garethw@syd.microforte.com.au]
Sent: Wednesday, October 10, 2001 9:26 PM
To: wxpython-users@lists.wxwindows.org
Subject: [wxPython] MVCTree and clicking events.
G'day all,
I am in the process of switching a wxPython app of mine from
using wxTreeCtrl to MVCTree and I have hit a bit of a stumbling block.
I have a module that contains the data that the MVCTree is representing and
a
TreeModel thats working to some extent.
What I would like to do is associate a pop up menu with each of the nodes
based on some of the methods in the classes represented by each of the
nodes, however I cannot work out how to get the right click event processed
correctly.
I tried creating a tree class of my own (derived from MVCTree) with an
EVT_RIGHT_DOWN handler
but this event is never caught by this handler.
I really don't have any idea where this should go, did I do the right thing
and just stuff it up
or have I got this all wrong?
This is the code fragment......
class MyTree( wxMVCTree ):
def __init__( self,parent ):
wxMVCTree.__init__( self,parent, -1 )
EVT_RIGHT_DOWN(self, self.onRightClick)
def onRightClick(self, event):
print "got a Right CLICK"
node = self.GetSelection()
popmenu = wxMenu("")
for method in node.publicMethods:
print "adding->", method.__name__
reuseId = addMenu(popmenu,method.__name__,method.__name__,method)
self.PopupMenu(popmenu,event.GetPosition())
TIA
----Gareth Walters
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users