[Tutor] Variable in tkinter?

R. Alan Monroe amonroe at columbus.rr.com
Sat Jul 23 13:55:03 EDT 2016

> button = tkinter.Button(frame, text='Up', command=click_up)
> button = tkinter.Button(frame, text='Down', command=click_down)

> when I first looked at it I thought it would not work, thinking that the
> second reference to button = would over write the first one.

It DOES overwrite it, in this sense:

The first button is a thing that exists because Button() generates it.
"button" is a word you can now use to refer to that thing.

Later on, the second call to Button() generates a new, separate thing.
"button" is now a word you can use to refer to the second thing,
but *the first thing doesn't cease to exist*.


More information about the Tutor mailing list