PyCommandEvent

K

Karsten

Hello,

I've got a question about Python Events. I want to generate a
PyCommandEvent (included in the wx Package). This PyCommandEvent ought
to be called when a method/function is called. I've seen some examples
in the www how I can call the Event when an other Event is called. But
this is not useful for me, because I want to generate a Event at runtime.
Example:
I've written a program which use the win32com interface of SAPI 5. When
a word is recognated, this word will be transported to the "major"
module by calling a method of a class within this method. When this
method is called I want, that the method generate/process a PyCommandEvent.

this code I have now:
##############################################################################
myEVT_SR_RECOGNITION = wx.NewEventType()
EVT_SR_RECOGNITION = wx.PyEventBinder(myEVT_SR_RECOGNITION, 1)

class COM_SR_REC:
def __init__(self):
print "init COM_SR_REC"

def OnRecognition(self,text):
print "I heared: " + text
make_event = MakeSREvent(text)

def MakeSREvent(self, text):
start_event = SR_Event(myEVT_SR_RECOGNITION,1)
start_event.WordRec(text)
self.GetEventHandler().ProcessEvent(start_event)
start_event.Skip()

class SR_Event(wx.PyCommandEvent):
def __init__(self, eventType, id):
wx.PyCommandEvent.__init__(self, eventType, id)
##################################################################

I think the class SR_EVENT works accurate. The problem is, that I can't
call the Event by using 'GetEventHandler' because there is no
EventHandler in class COM_SR_REC.
How can I call/process the Event???????
Is the rest of the code right???????

Next Question:
How can I listen to those PyCommandEvents from other modules?

Thanks for help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top