报错:
(venvSoc) I-PC-00000532:source gdlocal$ python gui_main.py
2021-06-02 19:34:02.984 python[6006:323959] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘NSWindow drag regions should only be invalidated on the Main Thread!’
def gui_thread():
root = tk.Tk()
app = gui_APP(root)
root.mainloop() # 消息循环
def main():
threading.Thread(target=gui_thread).start()
if __name__ == '__main__':
main()
原因:
在 windows 上运行一点问题都没有,是 Macbook 苹果电脑上控制了gui 运行只能主线程。
解决:
在 main 里面直接执行root.mainloop(),可以正常运行了。
def gui_thread():
root = tk.Tk()
app = gui_APP(root)
root.mainloop() # 消息循环
#def main():
# threading.Thread(target=gui_thread).start()
if __name__ == '__main__':
gui_thread()
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/101665.html