我的 Tkinter GUI 太……静态?
我使用 Tkinter GUI 来启动测量和分析过程,基本上只需单击按钮即可开始。由于这些测量可能需要一段时间,我尝试添加一个进度条,即这个:
http://tkinter .unpythonic.net/wiki/ProgressMeter
但是当我启动该过程时,我的整个 Tkinter 窗口变得毫无意义,直到测量完成并且它有点重新加载自己,我的进度条也设置为 100%。这有点不是我想要发生的事情。
那里发生了什么?我对整个编程事情还很陌生,所以我认为我没有所有的工具。我是否需要引入一个单独的线程或类似的东西,以便测量和 tkinter 主循环(是这样的?)同时运行?如果是这样,我该怎么做?
I use a Tkinter GUI to intiate a measurement and analysis process, which basically gets going with a clicked button. Since those measurements can take a while, I tried to include a progress bar, namely this one:
http://tkinter.unpythonic.net/wiki/ProgressMeter
But when I do initiate the process, my whole Tkinter window turns into nonsense until the measurement is done and it kinda reloads itself, with my progress bar set too 100%. This is kinda not what I wanted to happen.
What happened there? I am pretty new to this whole programming thing, so I don't have all the tools I guess. Do I need to introduce a seperate thread or something like that, so that the measurement and the tkinter mainloop (is that what that is?) run simultaneously? If so, how do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
制作一个进度条(这些是我处理 67MB 文件的代码片段。)
然后在分析过程中:
就像我说的,这将适用于我的 67MB 文件和 tkinter。
希望能有所帮助:)
Make a progressbar (these are snippets from my code that processes a 67MB file.)
then during your analysis:
Like I said this will work with my 67MB file and tkinter.
Hope that helps a little :)
每次更新进度条时调用
widget.update()
/root_window.update()
call
widget.update()
/root_window.update()
each time you update the progress bar