Create your own event class like this
wxEVT_WRITE_LOG = wxNewEventType()
def EVT_WRITE_LOG(win, func):
win.Connect(-1, -1, wxEVT_WRITE_LOG, func)
class WriteLogEvent(wxPyEvent):
def __init__(self, message):
wxPyEvent.__init__(self)
self.SetEventType(wxEVT_WRITE_LOG)
self.message = message
Then register this event with some window
EVT_WRITE_LOG(self, self.onWriteLog)
and write a handler for it, for example
def onWriteLog(self, event):
'''Action on an event to write a message to a log window.'''
self.displayMessage(event.message)
Then, when you need it, create an event object and post it to the window where it's registered
evt = WriteLogEvent(message)
wxPostEvent(self.__topframe, evt)
Any existing wx event can be created and posted this way
Marina Gourtovaia
Research Associate
Engineering Design Center
Department of Engineering
University of Cambridge
Cambridge, UK
Tel: +44 (0)1223 766961
Fax: +44 (0)1223 332662
···
gary.h.merrill@gsk.com wrote:
David: Thanks for the reply. I'll stick with 1 for now but keep your
other approach in mind for when I may need it.
I guess what I was in part really fishing for was how to programatically
emit an event (like raising an exception): some way to whap a wxWindows
object up side the head and make it emit an event. For now this is mostly
just curiosity, and it's not obvious to me that such a capability gets you
anything that you otherwise couldn't do. But if it's possible to do it,
I'd like to know.