Tkinter: bind Alt + mouse click

Ulrich Goertz ugoertz at mi.uni-koeln.de
Sun Sep 29 09:32:34 EDT 2002


Hi,

I am puzzled why I cannot bind events of the type "Alt" button press plus
mouse click. In other words, the following script which just opens a window
and should react on Alt-clicks by printing 'click', doesn't work for me:

# ---------------------------------
from Tkinter import *

def p(event): print 'click'

root = Tk()

f = Frame(root, width=100, height=100)
f.pack()
f.bind('<Alt-1>', p)

root.mainloop()
# ---------------------------------

(The window pops up, but nothing happens upon clicks.)

Everything works as expected if I replace <Alt-1> by <1>, <Control-1> or
<Shift-1>. I tried this on a Linux box with Python 2.0, 2.1 and 2.2, and
Tk 8.3. Any hints?

Ulrich




More information about the Python-list mailing list