如何阻止 Pyzo 调用 mainloop?

How do I stop Pyzo from calling mainloop?

我曾经为 Python 使用交互式编辑器,然后我 "upgraded" 使用 Pyzo(因为 IEP 已合并到 Pyzo)。我的一个程序使用 tkinter 创建 GUI。代码过去工作得很好:我将 运行 文件作为脚本,然后在解释器中调用 main,这将启动应用程序。

代码框架如下所示。

def main():
    class Application(tk.Frame):
        def __init__(self, master=None):
            # a bunch of stuff
        # several more methods here

    front=Application()
    front.mainloop()
# then I can either call main in the interpreter, or I can add this:
# the name==main part is to handle some multiprocessing that occurs within the application class
if __name__=="__main__":
    main()

这在 IEP 中非常有效。但是,在 Pyzo 中,main() 永远不会启动,或者更确切地说,它会启动,但是 gui 永远不会出现并且它不允许我做任何事情。相反,我收到此消息: 注意:GUI 事件循环已经在 pyzo 内核中 运行ning。注意进入主循环的函数不会阻塞。

当我使用 CPython 3 或 PyPy 解释器时,Pyzo 会出现此消息,但当我使用 Anaconda 3 时不会出现(我实际上需要使用 PyPy,因为我正在做的工作是计算量大)。

另一种选择是不使用 Pyzo,但这并不好玩。

我刚才发现了答案,但直到现在我才回来发布答案。本质上,Pyzo 本身有一个尝试检测 GUI 的设置。将该设置从自动切换为 none 解决了问题。