[Tutor] Variable in tkinter?

Jim Byrnes jf_byrnes at comcast.net
Sat Jul 23 11:38:52 EDT 2016


I have been working my way through a Python 3 book and got to the 
chapter on tkinter. The following is a segment of a example program that 
works:

# the views
frame = tkinter.Frame(window)
frame.pack()
button = tkinter.Button(frame, text='Up', command=click_up)
button.pack()
button = tkinter.Button(frame, text='Down', command=click_down)
button.pack()
label = tkinter.Label(frame, textvariable=counter)
label.pack()

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. Obviously 
that is wrong because the program does work.  Could someone explain to 
me why it works?

Regards,  Jim



More information about the Tutor mailing list