TKinter Button widget
Konrad Anton
usenet at minus1.de
Sat Apr 20 12:03:10 EDT 2002
Peter Saffrey <theoryboy at my-deja.com> schrieb:
>When I place some buttons on a frame I don't seem to be allowed to use
>arguments in the function call attached to the button. If I do use
>arguments, or even just empty brackets, the function is called when
>the button is placed, not when the button is clicked on.
>(...)
>Button(win, text='print 3', command=printNumber(3)).pack()
>Button(win, text='print 5', command=printNumber(5)).pack()
As long as there is no native support for currying in the Python
language, you can still use
Button(win, text='print 3', command=lambda : printNumber(3)).pack()
which will create a zero-argument anonymous function that will call
printNumber(3) when it is called.
HTH
Konrad
--
Konrad Anton <konrad at minus1.de> ; Web: www.minus1.de ; gpg: 0x22954D8A
Tel. +49-761-881-2122, Fax +49-721-151318943. Alice:
Yes!
More information about the Python-list
mailing list