问题:_tkinter.TclError: can't invoke "button" command: application has been destroyed
原因:将button(或者其他控件)创建在root.mainloop()语句前面,其中root就是你创建的窗口的名字。也就是要将窗口的控件全都创建完成后,再mainloop(),进入消息循环
文章讨论了在使用Python的Tkinter库时遇到的TclError,指出当试图在`root.mainloop()`之前创建按钮或其他控件时,因为应用已销毁导致命令无法执行。解决方法是确保所有控件都在消息循环开始前创建。
问题:_tkinter.TclError: can't invoke "button" command: application has been destroyed
原因:将button(或者其他控件)创建在root.mainloop()语句前面,其中root就是你创建的窗口的名字。也就是要将窗口的控件全都创建完成后,再mainloop(),进入消息循环
1万+
1万+

被折叠的 条评论
为什么被折叠?