Python 为什么特金特赢了';你不能得到我改变的价值吗?

Python 为什么特金特赢了';你不能得到我改变的价值吗?,python,tkinter,Python,Tkinter,经过多次研究,我无法成功地获得修改后的用户输入我的染色条目 def mail(value):     print(value) value = StringVar() value.set("Default text") entree = Entry(fenetre, textvariable=value, validate="key", width=30) entree.pack() value = value.get() bouton1=Button(fenetre, text="

经过多次研究,我无法成功地获得修改后的用户输入我的染色条目

def mail(value):
    print(value)    

value = StringVar() 
value.set("Default text")
entree = Entry(fenetre, textvariable=value, validate="key", width=30)
entree.pack()
value = value.get()
bouton1=Button(fenetre, text="Validate", command=lambda: mail(value))
bouton1.pack()
当我启动程序时,当我修改条目的文本时,当我单击validate时,文本值没有改变,为什么?
即使我更改了条目的标签,当我单击validate(验证)时,它也会始终将我打印为“默认文本”

您几乎立即将一个新值重新分配给
引用。首先执行
value=StringVar()
,然后执行几行
value=value.get()
。此时,
value
不再是
StringVar
;这只是一根绳子。删除第二个赋值,并使用
按钮更改行以检索值本身:

bouton1 = Button(fenetre, text="Validate", command=lambda: mail(value.get()))