[Tutor] Variable in tkinter?
Steven D'Aprano
steve at pearwood.info
Sun Jul 24 12:29:34 EDT 2016
On Sat, Jul 23, 2016 at 01:55:03PM -0400, R. Alan Monroe wrote:
> > 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*.
Why not? Why isn't the first button not garbage collected?
--
Steve
More information about the Tutor
mailing list