我的 Tkinter GUI 太......静态?

编程入门 行业动态 更新时间:2024-10-24 04:42:47
本文介绍了我的 Tkinter GUI 太......静态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-30 06:57:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1390778.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静态   Tkinter   GUI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!