[Tutor] How to enable pausing my stop_watch.py ?

Dick Moores rdm at rcblue.com
Thu Jul 8 10:39:17 CEST 2004


Dick Moores wrote at 01:16 7/8/2004:
>Alan Gauld wrote at 12:04 7/7/2004:

>>An example in my event driven programming topic in my tutor
>
>Here's that page without the frame:
>http://www.freenetpages.co.uk/hp/alan.gauld/tutevent.htm
>
>I'm afraid I don't understand enough to know where to put this line:
>self.txtBox.bind("<Key>", self.doKeyEvent)

I've got it now:
"""
from Tkinter import *

class KeysApp(Frame):
     def __init__(self):
         Frame.__init__(self)
         self.txtBox = Text(self)
         self.txtBox.bind("<space>", self.doQuitEvent)
         self.txtBox.pack()
         self.pack()
         self.txtBox.bind("<Key>", self.doKeyEvent)

     def doKeyEvent(self,event):
         str = "%d\n" % event.keycode
         self.txtBox.insert(END, str)
         return "break"

     def doQuitEvent(self,event):
         import sys
         sys.exit()


myApp = KeysApp()
myApp.mainloop()
""

Sorry about that.

Dick Moores




More information about the Tutor mailing list