在 tkinter Python 中使用 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()

为什么我看不到所有三个条目,它们在哪里?

但是当我这样做时:

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')

有效...

尝试将 "e" 改为 class,并分别声明您的盒子,a = b = e 给出的结果与您尝试的大致相同。

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()

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

您看不到三个条目,因为您没有创建三个条目。当您执行 a = b = c = e 时,您是将三个新名称分配给 e 所指的同一对象,而不是创建新的小部件。 abce 都引用内存中的同一个对象。