1 | #! /usr/bin/python |
---|
2 | """Displays the keysym for each KeyPress event as you type.""" |
---|
3 | |
---|
4 | # Copied from http://www.astro.washington.edu/owen/TkinterSummary.html |
---|
5 | |
---|
6 | import Tkinter |
---|
7 | |
---|
8 | root = Tkinter.Tk() |
---|
9 | root.title("Keysym Logger") |
---|
10 | |
---|
11 | def reportEvent(event): |
---|
12 | print 'keysym=%s, keysym_num=%s' % (event.keysym, event.keysym_num) |
---|
13 | |
---|
14 | text = Tkinter.Text(root, width=20, height=5, highlightthickness=2) |
---|
15 | |
---|
16 | text.bind('<KeyPress>', reportEvent) |
---|
17 | |
---|
18 | text.pack(expand=1, fill="both") |
---|
19 | text.focus_set() |
---|
20 | root.mainloop() |
---|