[wxPython] User-defined event class

I am trying to define my own events. In this context, I have several
questions:

  - How do I find a guaranteed unique event-ID for my new event?

  - I need to pass python objects trough the event system. Is this
    possible?

  - I would like to define my own event class derived from
    wxCommandEvent. I tried this, but (as I expected), after the Event
    has travelled to it's destination, the class has been chopped --
    it's only a wxCommandEvent not a MyEvent anymore :frowning: Is there any
    way to use user-defined python event classes? (If I need a few
    lines of C++ code, that would be OK, but I'd prefer a python-only
    solution)

Thanks for any answers,

Stefan.

I am trying to define my own events. In this context, I have several
questions:

  - How do I find a guaranteed unique event-ID for my new event?

wxNewEventType()

  - I need to pass python objects trough the event system. Is this
    possible?

See below.

  - I would like to define my own event class derived from
    wxCommandEvent. I tried this, but (as I expected), after the Event
    has travelled to it's destination, the class has been chopped --
    it's only a wxCommandEvent not a MyEvent anymore :frowning: Is there any
    way to use user-defined python event classes? (If I need a few
    lines of C++ code, that would be OK, but I'd prefer a python-only
    solution)

Derive your event class from wxPyCommandEvent. There is an example of doing
this in demo/PythonEvents.py.

···

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

"Robin Dunn" <robin@alldunn.com> writes:

> - How do I find a guaranteed unique event-ID for my new event?

wxNewEventType()

Ahh. Nice.

> - I would like to define my own event class derived from
> wxCommandEvent.

[...]

Derive your event class from wxPyCommandEvent. There is an example of doing
this in demo/PythonEvents.py.

Great !! Many thanks for your fast answer,

Stefan.