问题描述
限时送ChatGPT账号..我使用 Tkinter GUI 来启动测量和分析过程,这基本上是通过单击按钮开始的.由于这些测量可能需要一段时间,我尝试包含一个进度条,即这个:
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/wiki/ProgressMeter
但是当我开始这个过程时,我的整个 Tkinter 窗口都变成了无意义的,直到测量完成并且它有点重新加载自己,我的进度条设置为 100%.这有点不是我想要发生的.
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.
那里发生了什么?我对整个编程事物还很陌生,所以我没有我猜的所有工具.我是否需要引入一个单独的线程或类似的东西,以便测量和 tkinter 主循环(那是什么?)同时运行?如果是这样,我该怎么做?
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?
推荐答案
制作进度条(这些是我处理 67MB 文件的代码片段.)
Make a progressbar (these are snippets from my code that processes a 67MB file.)
progress = ttk.Progressbar(bottommenuframe, orient=HORIZONTAL, length=100, maximum=190073, mode='determinate')
progress.pack(side=RIGHT)
progress.start() ## this starts the progressbar
然后在您的分析过程中:
then during your analysis:
def analysisfunction():
progress.step(1)
##do some analysis
root.after(0, analysisFunction)
if job == complete:
stop
就像我说的,这适用于我的 67MB 文件和 tkinter.希望有点帮助:)
Like I said this will work with my 67MB file and tkinter. Hope that helps a little :)
这篇关于我的 Tkinter GUI 太......静态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论