无法在条目中看到文本

Can't see text in Entry

我在我的应用程序 windows 的主 windows 中使用了 Entry 字段,并使用了 StringVar 来填充它,它有效。现在,我创建了新的 window 并且我有一个新的 Entry 字段,我想填写与最初 window 相同的条目。我尝试使用与 main window 中使用的输入字段相同的变量,但我仍然看不到文本。

def napraviGUI(self):

self.__imeTxt = StringVar()
        self.__ime_entry = Entry(panelZaPrikaz,width=35,textvariable = self.__imeTxt,state=DISABLED)
        self.__ime_entry.grid(row=2,column=2)

def popuniEntry(self,jedanPacijent):
        self.__imeTxt.set(jedanPacijent.ime)

#this is inside second window
self.__ime_pregled_entry=Entry(self.prikazPacijenta,textvariable=self.__imeTxt,width=35,state=DISABLED)

self.__ime_pregled_entry.grid(row = 1,column = 2,sticky = NW)

#and this Entry don't show text

Tkinter 是一个单线程应用程序,因此您不能同时打开两个 windows。解决方案是创建第二个 window,就像第一个的 Toplevel。

您必须使用命令TopLevel(first_window)