1
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...

1
  • Yeah, You will have to explain harder than that because I don't understand what the problem is in my code. I understand your answer perfectly but I still don't understand what exactly is wrong in my code. Thanks. Commented Oct 2, 2018 at 10:33

2 Answers 2

2

Try to make "e" a class instead, and declare your boxes individually, a = b = e gives about the same result than what you tried.

root = Tk()
root.geometry("800x650")

class MyEntry(Entry):
    def __init__(self, master=root):
        Entry.__init__(self, master=root)

        self.configure(width = 3, 
            font = ('Verdana', 30),
            justify = 'right')

a = MyEntry()
b = MyEntry()
c = MyEntry()

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()
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.