Monitor all events for a widget

I fear this is a dumb question, but that never stopped me before...

Is there a simple way to monitor all events emitted by a particular widget and perhaps print the name of the event that was sent.

Use case: I'm working with a control I've never touched before (DataViewListCtrl) which has lots of events for which the descriptions in the docs all seem very similar. So I don't know what to Bind(). Would be nice if I could just create the widget, poke it a bit, and see what comes out.

Thanks,
Michael

What about running it with the WIT, e.g. create the app with:

from wx.lib.mixins import inspection
app = inspection.InspectableApp(0)

run your test app, ctrl-alt-i and start the Event Watcher

see in the wiki for more details on the WIT - http://wiki.wxpython.org/Widget%20Inspection%20Tool

Werner

···

On 24/02/2012 16:42, Michael Hipp wrote:

I fear this is a dumb question, but that never stopped me before...

Is there a simple way to monitor all events emitted by a particular widget and perhaps print the name of the event that was sent.

Use case: I'm working with a control I've never touched before (DataViewListCtrl) which has lots of events for which the descriptions in the docs all seem very similar. So I don't know what to Bind(). Would be nice if I could just create the widget, poke it a bit, and see what comes out.

Thanks, I've been using the WIT for a long time but never noticed it had an event monitor. After turning off all the SET_CURSOR events that buries it, I think it will do what I need.

Thanks,
Michael

···

On 2012-02-24 9:52 AM, werner wrote:

On 24/02/2012 16:42, Michael Hipp wrote:

Is there a simple way to monitor all events emitted by a particular widget
and perhaps print the name of the event that was sent.

What about running it with the WIT, e.g. create the app with:

I fear this is a dumb question, but that never stopped me before...

Is there a simple way to monitor all events emitted by a particular
widget and perhaps print the name of the event that was sent.

Use case: I'm working with a control I've never touched before
(DataViewListCtrl) which has lots of events for which the descriptions
in the docs all seem very similar. So I don't know what to Bind().
Would be nice if I could just create the widget, poke it a bit, and
see what comes out.

Thanks,
Michael

Just tried a little experiment:
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

import wx
e=wx.Event
dir(e)

['ClassName', 'Clone', 'Destroy', 'EventObject', 'EventType',
'GetClassName', 'G
etEventObject', 'GetEventType', 'GetId', 'GetSkipped', 'GetTimestamp',
'Id', 'Is
CommandEvent', 'IsSameAs', 'ResumePropagation', 'SetEventObject',
'SetEventType'
, 'SetId', 'SetTimestamp', 'ShouldPropagate', 'Skip', 'Skipped',
'StopPropagatio
n', 'Timestamp', '__class__', '__del__', '__delattr__', '__dict__',
'__doc__', '
__format__', '__getattribute__', '__hash__', '__init__', '__module__',
'__new__'
, '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str
__', '__subclasshook__', '__swig_destroy__', '__weakref__', 'thisown']

help(e.GetEventType)

Help on method GetEventType in module wx._core:

GetEventType(*args, **kwargs) unbound wx._core.Event method
    GetEventType(self) -> EventType

    Returns the identifier of the given event type, such as
    ``wxEVT_COMMAND_BUTTON_CLICKED``.

So if you bind an a single event handler to all the events for your
control you can print out the event types from within the handler...

Gadget/Steve

···

On 24/02/2012 3:42 PM, Michael Hipp wrote:

Unfortunately they will just be numbers at that point without any useful meaning attached to them. They will need to be mapped back to their EVT_ names to be recognizable by a human, and the event watcher in the WIT does that for you. You can also use the EventWatcher independently of the WIT if you want to, take a look at the wx.lib.eventwatcher module.

···

On 2/24/12 9:54 AM, Gadget/Steve wrote:

help(e.GetEventType)

Help on method GetEventType in module wx._core:

GetEventType(*args, **kwargs) unbound wx._core.Event method
     GetEventType(self) -> EventType

     Returns the identifier of the given event type, such as
     ``wxEVT_COMMAND_BUTTON_CLICKED``.

So if you bind an a single event handler to all the events for your
control you can print out the event types from within the handler...

--
Robin Dunn
Software Craftsman