Problem with processing PyCommandEvent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karsten

    #1

    Problem with processing PyCommandEvent

    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_RECOGN ITION = wx.NewEventType ()
    EVT_SR_RECOGNIT ION = wx.PyEventBinde r(myEVT_SR_RECO GNITION, 1)

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

    def OnRecognition(s elf,text):
    print "I heared: " + text
    make_event = MakeSREvent(tex t)

    def MakeSREvent(sel f, text):
    start_event = SR_Event(myEVT_ SR_RECOGNITION, 1)
    start_event.Wor dRec(text)
    self.GetEventHa ndler().Process Event(start_eve nt)
    start_event.Ski p()

    class SR_Event(wx.PyC ommandEvent):
    def __init__(self, eventType, id):
    wx.PyCommandEve nt.__init__(sel f, eventType, id)
    ############### ############### ############### ############### ######

    I think the class SR_EVENT works accurate. The problem is, that I can't
    call the Event by using 'GetEventHandle r' 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!
Working...