Button (command=funtion) in Tkinter: pasing arguments
revyakin
revyakin at yahoo.com
Thu Aug 29 23:23:33 EDT 2002
I am sorry for this, but my brain can't take it anymore
I would like a button on a Tk canvas to return its x,y coordinates
when pressed
def displayCoords(coords):
print coords
genericButton = Button(master=fileWindow,text='show coords')
currentButton = canvas.create_window(x,y,window=genericButton)
canvas.itemconfig(currentEventButton, tags=(x, y))
genericButton.config(command = displayCoords)
What I don't understand is how to pass the arguments to
displayCoords(coords).
If I write :
...command = displayCoords(canvas.gettags(currentButton))
displayCoords function just does not get invoked. It only gets invoked
when
it takes no arguments, but I DO NEED to pass the x,y to it in order to
display them, don't I? In fact, I looked through many config(command =
function)
exapmles and I've never seen any arguments passed to the function.
Can it be done at all?
More information about the Python-list
mailing list