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.
#!usr/bin/python
from Tkinter import *
def location(x,y):
print "I am in row ",x," and column ",y
root=Tk()
root.geometry('300x300')
can=Canvas(root,width=250, height=250)
bimage=PhotoImage(file='sq1.gif')
b1=Button(can,bg="black",image=bimage,command=location(0,0)).grid(row=0,column=0)
can.pack()
root.mainloop()
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),
-Phillip
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
