mainloop 阻止 Tkinter 应用程序从 IDLE 运行 [英] mainloop prevents Tkinter application to run from the IDLE

查看:29
本文介绍了mainloop 阻止 Tkinter 应用程序从 IDLE 运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Ubuntu 时,我可以通过在 IDLE 中编写命令来实时使用 Tk.

When using Ubuntu, I am able to play with Tk in real-time, by writing commands in the IDLE.

在 Windows 上,我需要调用 root.mainloop() 来生成一个窗口,循环阻止我从 IDLE 运行任何代码.

On Windows, I need to call root.mainloop() to spawn a window, and the loop keeps me from running any code from IDLE.

是平台的问题,还是我做错了什么?

Is it a matter of platform, or am I doing something wrong?

推荐答案

我没有完整的解决方案或答案,但我在这个主题上找到了一些东西:

I don't have a complete solution or answer, but here is something that I found on the subject:

从此页面:Tkinter 中的思考

请注意,您不应在 IDLE 下运行这些程序.IDLE 本身就是一个 Tkinter 应用程序,它有自己的主循环",会与这些程序中的主循环发生冲突.如果你真的想使用 IDLE 查看和运行这些程序,那么——对于每个程序——你应该在运行之前注释掉程序中的mainloop"语句.

Note that you should not run these programs under IDLE. IDLE is itself a Tkinter application, with its own "mainloop" that will conflict with the mainloop in these programs. If you really want to view and run these programs using IDLE, then -- for each program -- you should comment out the "mainloop" statement in the program before running it.

我不太确定背后的技术原因——但我只是不从 IDLE 运行 Tkinter 代码.

I'm not too sure about the technical reasons behind it -- but I just don't run Tkinter code from IDLE.

这篇关于mainloop 阻止 Tkinter 应用程序从 IDLE 运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆