[Tutor] Buttons automatically executing

Phillip Hart phillip.hart at gmail.com
Wed Jun 15 21:31:55 CEST 2005

Thanks for taking the time to read this.

Excuse me if this falls under the boundaries of a "newbie" question, as I am 
a self-taught programmer.

While using Tkinter to create buttons, something unexpected happens when the 
button commands call functions. Namely, when I run the following, it 
immediately executes the print statements without the button ever being 
pressed. Additionally, pressing the button once the Tk window is up will not 
activate the button.


from Tkinter import *

def location(x,y):
print "I am in row ",x," and column ",y

can=Canvas(root,width=250, height=250)




Lastly, when I change the command to be anything other than a function, such 
as a print statement, it works fine. What am I doing wrong here? 

thanks again for your time and help,

green python user (no pun intended),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050615/262de50b/attachment.htm

More information about the Tutor mailing list