I am attempting to create a popup menu when you right-click on an ogl shape
on a canvas. In the event handler for the right-click I call a panel where
I initiate the code for creating the pop-up menu. The error I get is:
Inappropriate argument type: Type error in argument 1 of
wxEvtHandler_Connect. Expected _wxEvtHandler_p.
Which is generated from:
File "C:\Python22\Lib\site-packages\wxPython\windows.py", line 54, in
Connect
val = windowsc.wxEvtHandler_Connect(self, *_args, **_kwargs)
Here is my panel where I attempt to create the pop-up menu:
class PopUpMenu(wxPanel):
def __init__(self, parent, xVal, yVal):
self.x = xVal
self.y = yVal
# only do this part the first time so the events are only bound
once
self.popupID1 = wxNewId()
self.popupID2 = wxNewId()
self.popupID3 = wxNewId()
# make a menu
menu = wxMenu()
# add some items
menu.Append(self.popupID1, "View")
menu.Append(self.popupID2, "Second")
menu.Append(self.popupID3, "Third")
EVT_MENU(self, self.popupID1, self.OnView)
EVT_MENU(self, self.popupID2, self.OnSecond)
EVT_MENU(self, self.popupID3, self.OnThird)
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
self.PopupMenu(menu, wxPoint(self.x, self.y))
#self.PopupMenu(menu, event.GetPosition())
#self.PopupMenu(menu, self.x, self.y)
menu.Destroy()
def OnView(self, event):
self.frame.notebook.AddNewPage(self.GetShape.GetText())
def OnSecond(self, event):
pass
def OnThird(self, event):
pass
I have gone back and forth between putting the popup menu directly in the
wxShapeEvtHandler but it seems to require being subclassed off of a panel.
Any idea where I'm going wrong?
···
-----------------------------------------------------------------------
Natalie Doe
Software Engineer
Data Exploration Sciences, New Applications
GlaxoSmithKline
(919) 315-4963