Search code examples
pythonpython-3.xtkintertkinter-entry

Having trouble with Entry variables in tkinter Python


from tkinter import *

root = Tk()
root.geometry("800x650")
e = Entry(root, width=3, font=('Verdana', 30), justify='right')

a = b = c = e

a.place(relx=0.2, rely=0.5, anchor=CENTER)
b.place(relx=0.44, rely=0.5, anchor=CENTER)
c.place(relx=0.65, rely=0.5, anchor=CENTER)
root.mainloop()

Why can't I see all three entries, where are they?

But when I do this:

a = Entry(root, width=3, font=('Verdana', 30), justify='right')
b = Entry(root, width=3, font=('Verdana', 30), justify='right')
c = Entry(root, width=3, font=('Verdana', 30), justify='right')

it works...


Solution

  • Why can't I see all three entries, where are they?

    You can't see three entries because you didn't create three entries. When you do a = b = c = e, you are assigning three new names to the same object that e refers to, you aren't creating new widgets. a, b, c, and e all refer to the same object in memory.