Por que chamar entry.get () me dá "nome de comando inválido"?
Este é o meu código:
def ask(what,why):
root=Tk()
root.title(why)
label=Label(root,text=what)
label.pack()
entry=Entry(root)
entry.pack()
button=Button(root,text='OK',command=root.destroy)
button.pack()
root.mainloop()
return entry.get()
E quando eu chamo o código:
print(ask('Name:','Hello!'))
Eu recebo:
Traceback (most recent call last):
File "C:\gui.py", line 16, in <module>
ask('Name:','Hello!')
File "C:\gui.py", line 15, in ask
return entry.get()
File "C:\Python34\lib\tkinter\__init__.py", line 2520, in get
return self.tk.call(self._w, 'get')
_tkinter.TclError: invalid command name ".48148176"
Estou usando o Python 3.4.3 no Windows 7 de 32 bits.