小编use*_*823的帖子

RuntimeError:主线程不在主循环中

我打电话的时候

self.client = ThreadedClient() 
Run Code Online (Sandbox Code Playgroud)

在我的Python程序中,我收到错误

"RuntimeError:主线程不在主循环中"

我已经做了一些谷歌搜索,但我在某种程度上犯了错误...有人可以帮助我吗?

完整错误:

Exception in thread Thread-1:
    Traceback (most recent call last):
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 530, in __bootstrap_inner
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 483, in run
    File "/Users/Wim/Bird Swarm/bird_swarm.py", line 156, in workerGuiThread
    self.root.after(200, self.workerGuiThread)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 501, in after
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1098, in _register
    RuntimeError: main thread is not in main loop
Run Code Online (Sandbox Code Playgroud)

类别:

class ThreadedClient(object):

    def __init__(self):
        self.queue = Queue.Queue( )
        self.gui = GuiPart(self.queue, self.endApplication)
        self.root = self.gui.getRoot()
        self.running = True
        self.GuiThread = threading.Thread(target=self.workerGuiThread) …
Run Code Online (Sandbox Code Playgroud)

python multithreading tkinter

24
推荐指数
3
解决办法
5万
查看次数

标签 统计

multithreading ×1

python ×1

tkinter ×1