What is wx.Menu.Connect()?

What is wx.Menu.Connect()?

I haven't found much documention on the wx.Menu.Connect method am I'm
not sure what it is used for. Considering my home baked method below,
would the Connect() method be the best approach? C++ just confuses me
btw.

I find I do a lot of this for menus:
   menuItem = app.Append(ID_EXIT, "E&xit", "Close the entire
application")
   self.Bind(wx.EVT_MENU, self.OnExit, menuItem)

So I thought I'd make a new menu class with a method as something
like:
    def BindMenuItem(self, menu, id, method, menu, sbTip):
        # couldn't come up with a good method name for this.
        menuItem = menu.Append( id, menu, sbTip)
        self.Bind(wx.EVT_MENU, method, menuItem)
        return menuItem

And came across this tutorial for wx.Menus using Connect() in other
languages:
    Some language similar to Python
    http://brucey.net/programming/blitz/tutorials/prog/en/menustoolbars.html

    and here in C++
    http://zetcode.com/tutorials/wxwidgetstutorial/menustoolbars/

But the wxPython tutorial version of this webpage doesn't demo the
Connect() method:
    http://zetcode.com/wxpython/menustoolbars/

What is wx.Menu.Connect()?

It is inherited from wx.EvtHandler, and is what is used inside the Bind method and the PyEventBinder objects for making the event bindings.

I haven't found much documention on the wx.Menu.Connect method am I'm
not sure what it is used for. Considering my home baked method below,
would the Connect() method be the best approach? C++ just confuses me
btw.

It usually isn't a good idea to try binding menu events directly to the menu, there are some inconsistencies across platforms whether the event will actually be delivered there or not. Instead you can bind to the frame in the case of menu bars, or to the window that does PopupMenu() for popups.

I find I do a lot of this for menus:
    menuItem = app.Append(ID_EXIT, "E&xit", "Close the entire
application")
    self.Bind(wx.EVT_MENU, self.OnExit, menuItem)

So I thought I'd make a new menu class with a method as something
like:
     def BindMenuItem(self, menu, id, method, menu, sbTip):
         # couldn't come up with a good method name for this.
         menuItem = menu.Append( id, menu, sbTip)
         self.Bind(wx.EVT_MENU, method, menuItem)
         return menuItem

And came across this tutorial for wx.Menus using Connect() in other
languages:
     Some language similar to Python
     Menus and Toolbars

In this case it's not calling Conenct on a menu, but on a wxFrame class that is called SimpleMenu. Very poor choice in names IMO.

     and here in C++
     http://zetcode.com/tutorials/wxwidgetstutorial/menustoolbars/

Same here.

But the wxPython tutorial version of this webpage doesn't demo the
Connect() method:
     http://zetcode.com/wxpython/menustoolbars/

And here they are using self.Bind instead.

···

On 10/12/10 6:00 PM, DevPlayer wrote:

--
Robin Dunn
Software Craftsman