Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Python: Key action: Right key

Python:  Key action: Right key
{filelink=15667}

from Tkinter import *
class KeyEvents(Frame):
    def __init__(self, parent=None):
        Frame.__init__( self )
        self.master.title("Keyboard arrow key")
        self.master.geometry("150x100")         # widows size
        self.pack(expand=YES, fill=BOTH)
        lbl=Label(self, text="Press on an arrow key")
        lbl["bg"]="blue"
        lbl["font"]=('courier', 20, 'bold')
        lbl.pack(expand=YES, fill=BOTH)
        lbl.focus()
        lbl.bind("", self.onArrawKey)    # '-->'
        lbl.bind("", self.onArrawKey)     # '", self.onArrawKey)
        lbl.bind("", self.onArrawKey)
    def onArrawKey(self,event):
        print "The user pressed on an arrow key"
def main():
   KeyEvents().mainloop()
if __name__=="__main__":
    main()

No comments yet.

Leave a Comment