Tkinter的多处理池不起作用

时间:2020-02-01 07:36:14

标签: python tkinter multiprocessing

我是python的新手,我在tkinter和多处理方面都遇到了麻烦。我已经阅读了几篇材料,但我想我无法掌握一个我的案例可以理解的例子。但是,我最终决定使用Pool模块。在我得到的示例中,他们使用了map,但是由于没有可迭代性,因此我将无法使用。我试图使用starmap和其他选项apply_async,但仍然无法正常工作。我的jupyter笔记本将仅反映它当前正在运行代码,但不会出现GUI。

到目前为止,这是我的代码。我赞赏善意和具体的例子。谢谢。

# I just skipped the initial parts of the script, I just really focused on the multiprocessing parts
def main_function(): 
    root = Tk()
    MainApplication(root).pack() #this is the class I put all the widgets needed
    root.mainloop()

if __name__ == "__main__":
    p = Pool()
    p.starmap(main_function, [() for _ in range(10)])

    p.close()
    p.join()

0 个答案:

没有答案
相关问题