如何在 kivy-python 中使用具有多线程的时钟对象更新进度条?
问题描述
我正在 kivy 中制作一个应用程序,因为我正在使用 linux.我在使用 python-kivy 中的多线程时钟对象更新进度条 gui 时遇到问题.我正在使用这两个文件 .kv &.py 文件运行应用程序.
I am making an app in kivy for that i am using linux. i am getting a problem to update the progress bar gui using clock object with multithreading in python-kivy. i am using both files .kv & .py file run the app.
我的 main.py 文件:
my main.py file:
我的 .kv 文件:
进度条是否完美更新?我想在实时更新它.请告诉我执行此代码的更好方法.提前致谢.
Is the progress bar perfectly updating? i want upate it prefectly in live time. Please tell me the better way to execute this code. Thanks in advance.
推荐答案
你的代码有几个问题:
您的 UI 线程中有一个循环(这将停止 UI 更新)
You have a loop in your UI thread (which will stop the UI updating)
您需要像这样将循环传递到您的线程中:
You need to pass the loop into your thread like this:
还有更多的修复需要完成(风格方面),但这超出了上下文
There are more fixes to be done (style wise) but that is outside the context
注意 - 这未经任何测试...
Note - this was not tested by any means...
这篇关于如何在 kivy-python 中使用具有多线程的时钟对象更新进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!