problems listening for an event

7stud bbxx789_05ss at yahoo.com
Tue May 29 23:32:29 PDT 2007


1) Can anyone tell me why the code that's commented fails to call 
the event handler:


class MyFrame(wx.Frame):
    def __init__(self, mytitle):
        wx.Frame.__init__(self, parent=None, title=mytitle)
        mypanel = wx.Panel(self)

        mybutton = wx.Button(mypanel, -1, "click me")
        self.Bind(wx.EVT_BUTTON, self.doSomething, mybutton)

        #myTextBox = wx.TextCtrl(mypanel, -1, pos=(0, 100))
        #self.Bind(wx.EVT_KEY_DOWN, self.doSomething, myTextBox)

        myTextBox = wx.TextCtrl(mypanel, -1, pos=(0, 100))
        myTextBox.Bind(wx.EVT_KEY_DOWN, self.doSomething)
        
    def doSomething(self, event): 
        print("hello")



class MyApp(wx.App):
    def __init__(self):
        wx.App.__init__(self, redirect=False)

app = MyApp() 
win = MyFrame("test")
win.Show()
app.MainLoop()       








More information about the wxpython-users mailing list