Ticket #15706: test.py

File test.py, 499 bytes (added by tom.duck@…, 16 years ago)

python/tk test program

Line 
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
6import Tkinter
7       
8root = Tkinter.Tk()
9root.title("Keysym Logger")
10       
11def reportEvent(event):
12    print 'keysym=%s, keysym_num=%s' % (event.keysym, event.keysym_num)
13       
14text  = Tkinter.Text(root, width=20, height=5, highlightthickness=2)
15   
16text.bind('<KeyPress>', reportEvent)
17       
18text.pack(expand=1, fill="both")
19text.focus_set()
20root.mainloop()