Tkinter Button widget
William Park
opengeometry at yahoo.ca
Thu Jul 14 16:31:55 EDT 2005
Peter Otten <__peter__ at web.de> wrote:
> Shankar Iyer (siyer at Princeton.EDU) wrote:
>
> > I have another Tkinter-related question. At the beginning of my
> > program, a tkinter window is created with six buttons. Each of these
> > buttons is assigned a function that should be executed only when the
> > button is pressed. However, it seems that these functions are all
> > executed once when the button widgets are first created. Why is this
> > the case and how do I prevent this from happening?
>
> Change your source code from
>
> # wrong
> button = Tkinter.Button(..., command=some_function(),...)
>
> to
>
> # correct
> button = Tkinter.Button(..., command=some_function,...)
>
> to pass the *function* to the widget instead of the *result* of a
> function call. And, next time, remember to post some code alongside
> with your question.
Hmm, maybe I should learn Tk + Python. Telepathetic powers of Python
programmers are amazing.
--
William Park <opengeometry at yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
More information about the Python-list
mailing list