Tkinter callback problem

Ian Terrell kife00 at
Thu Mar 13 18:18:08 CET 2003

I'm trying to run the following code I found in some tutorial:

from Tkinter import *

def button1(event):
    print "Clicked at",event.x,event.y

root = Tk()

frame = Frame(root, width=100, height=100)
frame.bind("<Button-1>", button1)


It starts up just fine.  However, when I click on the window, I get
the following runtime error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.2/lib-tk/", line 1300, in
    args = apply(self.subst, args)
  File "/usr/local/lib/python2.2/lib-tk/", line 1036, in
    e.height = getint(h)
ValueError: invalid literal for int(): ??

Now, to fix this, I started by commenting out the e.height = getint(h)
line, and got more errors of the same variety for other variables.  If
I comment out the following lines from's _substitute
function, it works perfectly:

#        e.height = getint(h)
#        e.keycode = getint(k)
#        e.width = getint(w)
#        e.keysym_num = getint(N)

Is this something to do with the fact that a frame was clicked in? 
Perhaps frames don't have heights, keycodes, widths, or keysys_nums?

Is there a more elegant solution to this so that it works?


More information about the Python-list mailing list