Shatnerz
Shatnerz

Reputation: 2543

wxpython - Post custom event that propagates

Right now I have a child panel that post some event. I've tried

    myEvent = events.ChangedAvailModelsEvent()
    #self.GetEventHandler().ProcessEvent(myEvent)
    wx.PostEvent(self, myEvent)

I create my event with

ChangedAvailModelsEvent, EVT_CHANGEDAVAILMODELS = NewEvent()

I bind with

self.Bind(events.EVT_CHANGEDAVAILMODELS, self.OnUpdate)

which takes place in some nth grandparent. I have print statements telling me the event was processed, but I my function is never called afterwards. I'm not sure what the problem is. I feel like the event is not propagating upwards. Any help?

Upvotes: 0

Views: 304

Answers (1)

RobinDunn
RobinDunn

Reputation: 6206

Change it to use NewCommandEvent instead of NewEvent. Command events will automatically propagate up the parent chain in search of a handler. Non-command events will only be processed by the object they are posted to. See http://wiki.wxpython.org/self.Bind_vs._self.button.Bind.

Upvotes: 1

Related Questions