My top-level window needs to know when the internal state of a custom control changes so it can update various other parts of the GUI. How do I generate a custom event in the control, so it can propagate and be handled by the top-level window?
I know this is an old question, but there is a newer, slightly nicer, way to do this in wxPython. Paraphrased from http://wiki.wxpython.org/CustomEventClasses and the above:
To define the event:
import wx.lib.newevent
QuantityChangedEvent, EVT_QUANTITY_CHANGED = wx.lib.newevent.NewCommandEvent()
To generate an event:
event = QuantityChangedEvent(self.GetId())
self.GetEventHandler().ProcessEvent(event)
# or ...
#wx.PostEvent(self, event)
Binding the event remains the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With