Documentation of types of arguments that can be passed to events

The only time I’ve seen events is when they are passed as arguments to the bind function. Ex:

Text.Bind(wx.EVT_KEY_DOWN, self.OnKeyText)

However I was going through the tutorial here http://wiki.wxpython.org/DragAndDrop and noticed that numerous arguments are being passed to the event wx.EVT_RIGHT_DOWN (right click on mouse)

wx.EVT_RIGHT_DOWN(self.text, self.OnDragInit)

and also this

wx.EVT_MENU(self, MENU_FILE_EXIT, self.CloseWindow)

I looked around for documentation on the constructor of the event class but only found this which shows that the constructor takes only a single argument.
http://wxpython.org/docs/api/wx.MouseEvent-class.html

What documentation can I look at to understand the types of arguments an EVT can take?

RedHotChiliPepper wrote:

The only time I've seen events is when they are passed as arguments to
the bind function. Ex:

Text.Bind(wx.EVT_KEY_DOWN, self.OnKeyText)

However I was going through the tutorial here
DragAndDrop - wxPyWiki and noticed that numerous arguments
are being passed to the event wx.EVT_RIGHT_DOWN (right click on mouse)

wx.EVT_RIGHT_DOWN(self.text, self.OnDragInit)

and also this

wx.EVT_MENU(self, MENU_FILE_EXIT, self.CloseWindow)

That's the (very) old way to bind events. Those are equivalent to the following:

     self.text.Bind(wx.EVT_RIGHT_DOWN, self.OnDragInit)
     self.Bind(wx.EVT_MENU, self.CloseWindow, id=MENU_FILE_EXIT)

Originally the wx.EVT_WHATEVER items were functions. Now they are instances of a wx.PyEventBinder which also have a __call__ magic method for backwards compatibility. Any new code should use the Bind method instead of the function call version of the event binders. There aren't any plans for removing it now but I can't promise that the old style will stay forever.

I looked around for documentation on the constructor

of the event class but only found this which shows that the constructor takes only a single argument.

wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

That's different. wx.MouseEvent and other event classes are the classes of the objects that are passed to the event handlers. The wx.EVT_* items are the things that bind events to handlers.

···

--
Robin Dunn
Software Craftsman

Thanks Robin for your succinct and prompt reply. It all makes sense now.

···

On Saturday, July 20, 2013 10:24:08 PM UTC-4, Robin Dunn wrote:

RedHotChiliPepper wrote:

The only time I’ve seen events is when they are passed as arguments to

the bind function. Ex:

Text.Bind(wx.EVT_KEY_DOWN, self.OnKeyText)

However I was going through the tutorial here

http://wiki.wxpython.org/DragAndDrop and noticed that numerous arguments

are being passed to the event wx.EVT_RIGHT_DOWN (right click on mouse)

wx.EVT_RIGHT_DOWN(self.text, self.OnDragInit)

and also this

wx.EVT_MENU(self, MENU_FILE_EXIT, self.CloseWindow)

That’s the (very) old way to bind events. Those are equivalent to the
following:

 self.text.Bind(wx.EVT_RIGHT_DOWN, self.OnDragInit)

 self.Bind(wx.EVT_MENU, self.CloseWindow, id=MENU_FILE_EXIT)

Originally the wx.EVT_WHATEVER items were functions. Now they are
instances of a wx.PyEventBinder which also have a call magic method
for backwards compatibility. Any new code should use the Bind method
instead of the function call version of the event binders. There aren’t
any plans for removing it now but I can’t promise that the old style
will stay forever.

I looked around for documentation on the constructor

of the event class but only found this which shows that the constructor
takes only a single argument.

http://wxpython.org/docs/api/wx.MouseEvent-class.html

That’s different. wx.MouseEvent and other event classes are the classes
of the objects that are passed to the event handlers. The wx.EVT_*
items are the things that bind events to handlers.


Robin Dunn

Software Craftsman

http://wxPython.org