tkinter bug? tk bug?

Drew Perttula drewp at bigasterisk.com
Sat Nov 2 20:45:41 EST 2002


"Michael Bakkemo" <a at b.c> wrote in message news:<apvaej$9ha$0 at 216.39.145.102>...
> 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:

# I made the code a lot shorter. I assume this still exhibits the
error:

import Tkinter

def KeyDown(ke):
    print "keydown:", ke.keysym_num, ke.keycode, ke.keysym

def KeyUp(ke):
    print "keyup:", ke.keysym_num, ke.keycode, ke.keysym

root = Tkinter.Tk()

root.bind("<Key>", KeyDown)
root.bind("<KeyRelease>", 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?
> 

With the code above, I get good behavior on left and right control,
alt, and shift. Have you tried the 'xev' utility? That would help you
separate a
symbol list typo in tk, etc, from a funny keyboard mapping in your
windowing
system.

-Drew



More information about the Python-list mailing list