方法一(Tkinter) 最后写 root.mainloop() 当然,如果不是root,则应使用Tk对象的名称代替root。 方法二(多线程) 将线程设置为守护程序 t = threading.Thread(target=your_func)t.setDaemon(True)t.start() daemon默认是False,将其设置为True,再Start,就可以解决问题。da
t=threading.Thread(target=your_func)t.setDaemon(True)t.start() daemon默认是False,将其设置为True,再Start,就可以解决问题。daemon为True,就是我们平常理解的后台线程,用Ctrl-C关闭程序,所有后台线程都会被自动关闭。如果daemon属性是False,线程不会随主线程的结束而结束,这时如果线程访问主线程的资源,就会出错。
1. 解释“RuntimeError: main thread is not in main loop”错误的含义 RuntimeError: main thread is not in main loop 这个错误通常出现在使用GUI(图形用户界面)框架(如Tkinter、PyQt等)和多线程编程的环境中。这个错误表明某个非主线程尝试执行了只能在主线程中安全执行的GUI操作,如更新GUI组件或触发GUI事件。
A separate application is the only way I can think of showing a GUI if you cannot run PySimpleGUI as the main thread. I run PySimpleGUI programs "in the background" and in the system tray all day... they all run as the main thread. With tkinter, you don't have any choice. If...
How to Fix the Main Thread is not in Main Loop Error? The following are the solutions to solve the error Runtimeerror main thread is not in main loop. Solution 1: Using the Tkinter after() Method The first way to solve this error is by using Tkinter after() Method. ...
: <function Variable.__del__ at 0x0000023DD71EAB80> Traceback (most recent call last): File "C:\python39\lib\tkinter\__init__.py", line 363, in __del__ if self._tk.getboolean(self._tk.call("info", "exists", self._name)): RuntimeError: main thread is not in main loop...
RuntimeError: main thread is not in main loopException ignored in: <bound method Image.__del__ of <tkinter.PhotoImage object at 0x000001AF6410B5F8>>Traceback (most recent call last): File "C:\Python36\lib\tkinter\__init__.py", line 3504, in __del__ self.tk...
RuntimeError: main thread is not in main loop [[Node: Loss/PyFunc_1 = PyFunc[Tin=[DT_FLOAT], Tout=[DT_UINT8], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/device:CPU:0"](Loss/Squeeze_1/_6143)]] Caused by op u'Loss/PyFunc_1', defined at: ...
当前标签:RuntimeError: main thread is not in main loop tensorflow_目标识别object_detection_api,RuntimeError: main thread is not in main loop,fig = plt.figure(frameon=False)_tkinter.TclError: no display name and no $DISPLAY environment variable youxiaogeo 2018-10-28 21:18 阅读:...
del of <tkinter.PhotoImage object at 0x7f1b5f86a710>> Traceback (most recent call last): File "/usr/lib/python3.5/tkinter/init.py", line 3359, in del self.tk.call('image', 'delete', self.name) RuntimeError: main thread is not in main loop Owner r9y9 commented Nov 23, 2017 ...