[wxPython] Custom events

I have what I think is a pretty simple problem, but for the life of me I
can't figure it out. I would like to create my own events. I'm writing an
instant messenger client and I would like to have one thread maintain the
connection to the server and when it receives a message or other event, send
an event through the wxEvent system that I can catch from my GUI layer. I'm
having problems with merely subclassing wxEvent, in particular it doesn't
like me calling the superclass's constructor wxEvent.__init__(self)
Any idea how to go about creating custom events?

-Casey

I have what I think is a pretty simple problem, but for the life of me I
can't figure it out. I would like to create my own events. I'm writing an
instant messenger client and I would like to have one thread maintain the
connection to the server and when it receives a message or other event,

send

an event through the wxEvent system that I can catch from my GUI layer.

I'm

having problems with merely subclassing wxEvent, in particular it doesn't
like me calling the superclass's constructor wxEvent.__init__(self)
Any idea how to go about creating custom events?

See the demo. (Hint, you want to derive from wxPyEvent.)

···

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

take a look at the source maybe it helps ...

from wxPython import wx

wxEVT_MYFOO = 25001
def EVT_BOOTP(win, func):
    win.Connect(-1, -1, wxEVT_MYFOO, func)

class CEvent_Foo(wx.wxPyEvent):
    def __init__(self, anything):
        wx.wxPyEvent.__init__(self)
        self.anything = anything

                    evt = CEvent_Foo(333, 123 )
                    wxPostEvent(tree, evt)
                    del evt

···

----- Original Message -----
From: "Casey Crabb" <debug@discobob.dyndns.org>
To: <wxpython-users@lists.wxwindows.org>
Sent: Monday, September 10, 2001 4:31 PM
Subject: [wxPython] Custom events

I have what I think is a pretty simple problem, but for the life of me I
can't figure it out. I would like to create my own events. I'm writing an
instant messenger client and I would like to have one thread maintain the
connection to the server and when it receives a message or other event,

send

an event through the wxEvent system that I can catch from my GUI layer.

I'm

having problems with merely subclassing wxEvent, in particular it doesn't
like me calling the superclass's constructor wxEvent.__init__(self)
Any idea how to go about creating custom events?

-Casey

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

Thanks ssh-gmx and Robin for your help. It got me on the right track and its
working now.

Casey