Created
August 26, 2014 18:06
-
-
Save driscollis/69b83f6b1a53f533eeb6 to your computer and use it in GitHub Desktop.
wxPython multiple events on the same handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wx | |
class MyForm(wx.Frame): | |
#---------------------------------------------------------------------- | |
def __init__(self): | |
wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial", size=(500,500)) | |
# Add a panel so it looks the correct on all platforms | |
panel = wx.Panel(self, wx.ID_ANY) | |
text = wx.TextCtrl(panel) | |
text.SetFocus() | |
text.Bind(wx.EVT_TEXT, self.onKey) | |
text.Bind(wx.EVT_KEY_DOWN, self.onKey) | |
#---------------------------------------------------------------------- | |
def onKey(self, event): | |
"""""" | |
if hasattr(event, "GetKeyCode"): | |
print "event fired by EVT_KEY_DOWN" | |
else: | |
print "event fired by EVT_TEXT" | |
event.Skip() | |
# Run the program | |
if __name__ == "__main__": | |
app = wx.App(False) | |
frame = MyForm() | |
frame.Show() | |
app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment