PopupMenu Error

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

Seems like you forgot to do wxPanel.__init__(self, parent, id, ...) in the
__init__ method.

···

On Mon, 10 Nov 2003 natalie.l.doe@gsk.com wrote:

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):

*----------------------------------------------
need wxPanel.__init__ here!!!
*----------------------------------------------

        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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

···

natalie.l.doe@gsk.com wrote:
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Because you don't call wxPanel.__init__, but why do you need the other panel? Just use the shape canvas.

···

natalie.l.doe@gsk.com wrote:

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.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!