tkinter bug? tk bug?
Michael Bakkemo
a at b.c
Fri Nov 1 20:40:35 EST 2002
I am not sure where things are going wrong, but binding to the "<Key>" and
"<KeyRelease>" TK events seems to work fine except for the right side
control and alt keys: the <Key> event hands me the correct values, but the
<KeyRelease> event hands me the left side values. To wit:
# File: keys.py
import Tkinter
import Pmw
import tkFont
import sys
class KeyboardHandler:
def __init__(self):
pass
def _Log(self, string):
print string
def KeyDown(self, ke):
print "keydown:", ke.keysym_num, ke.keycode, ke.keysym
def KeyUp(self, ke):
print "keyup:", ke.keysym_num, ke.keycode, ke.keysym
def bail():
menu.quit()
root = Tkinter.Tk()
# create a menu
menu = Tkinter.Menu(root)
root.config(menu=menu)
Quitmenu = Tkinter.Menu(menu)
menu.add_cascade(label="Quit", menu=Quitmenu)
Quitmenu.add_command(label="Quit", command=bail)
sc = Pmw.ScrolledCanvas(root, borderframe=1, hscrollmode='dynamic',
vscrollmode='dynamic')
sc.resizescrollregion()
sc.pack(fill='both',expand=1)
keyb = KeyboardHandler()
root.bind("<Key>", keyb.KeyDown)
root.bind("<KeyRelease>", keyb.KeyUp)
root.mainloop()
gives me the following when the right side Alt and Control keys are pressed
and released.
>>>
keydown: 65514 18 Alt_R
keyup: 65513 18 Alt_L
keydown: 65508 17 Control_R
keyup: 65507 17 Control_L
My question is, where (what level) are things going wrong? I doubt it is my
code (but hey, what do I know) tkinter? the tk level? my keyboard driver?
Any pointers appreciated.
More information about the Python-list
mailing list