python2 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()#gui_thread()
·
报错:
(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()
更多推荐

所有评论(0)