Connect

Hi,

just reading

http://wiki.wxpython.org/Avoiding EVT_MENU

Not sure why binding EVT_MENU (or generally event) is ugly - it's not
explained there...

Thanks for clarification...

Martin

···

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Martin Landa wrote:

Hi,

just reading

http://wiki.wxpython.org/Avoiding EVT_MENU

Not sure why binding EVT_MENU (or generally event) is ugly - it's not
explained there...

Thanks for clarification...

The page is full of hot air[*]. There is no functional, conceptual, OO or Pythonic difference between

  frame.Connect(ID_About, -1,
    wx.wxEVT_COMMAND_MENU_SELECTED, frame.OnAbout)

and

  frame.Bind(wx.EVT_MENU, frame.OnAbout, id=ID_About)

other than the 2nd one being easier to type. And if OO encapsulation is important to you then the Connect or Bind should be being done in the Frame class's __init__ anyway.

[*] The unpythonic thing the page may be referring to is the very old way to do event bindings before we had Bind:

  wx.EVT_MENU(frame, ID_About, frame.OnAbout)

This style still works but has been discouraged for several years.

···

--
Robin Dunn
Software Craftsman