我正在尝试制作一个弹出窗口,人们可以在其中填写输入框中的字符串。我已经经历了很多例子,但它不起作用。
我正在尝试这样做:
var_entry = simpledialog.askstring("Test", "Test")
我收到此错误消息:
_tkinter.TclError: window ".!_querystring" was deleted before its visibility changed
提前致谢!
编辑:发布错误的错误消息
我知道这是一个旧线程,但我遇到了同样的问题,到目前为止还没有找到根本原因。
但是,如果其他人需要它,此解决方法对我有用:
#Create a new temporary "parent"
newWin = Tk()
#But make it invisible
newWin.withdraw()
#Now this works without throwing an exception:
retVal = simpledialog.askstring("Enter Value","Please enter a value",parent=newWin)
#Destroy the temporary "parent"
newWin.destroy()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)