Keyboard Commands

QWE leomasi at libero.it
Mon Apr 21 07:16:27 EDT 2003


On Sun, 20 Apr 2003 18:27:21 -0500, "richard.a.charts.1"
<charts at purdue.edu> wrote:

>Hey,
>I'm working on a program and I want to use keyboard shortcuts for some of
>my menu items.  I can't seem to find the way to implement this.  Can
>anyone point me in the right direction?  ex.  Ctrl-x, ctrl-F1, etc.
>
>Thanks for any help.
>And please feel free to email ur answers to me directly.
>
>Charts
from Tkinter import *

root = Tk()

def hello():
    print "Hello"

frame = Frame(root)
root.bind("<Control-p>", lambda e: hello())
Label(text="Press Controll-p").pack()
frame.pack()

root.mainloop()





More information about the Python-list mailing list