问题描述
我在一个项目上工作:程序下载但我在使用 while 循环时遇到问题,用于检查与 Internet 的连接,如果 true 不 setText('') to lable 和 if Flase setText('anyText') to lable
I work on one Project : Program download but I have a problem with while loop for check the connection with the internet and if true doesn't setText('') to lable and if Flase setText('anyText') to lable
连接检查方法
我已经厌倦了 QThread .请问我该怎么做:)?如果连接丢失=False setText('check internet') 以及连接变为 true 时,应用程序正在运行时 setText('')
I have tired with QThread . Please How I can do it :) ? And when app is running if connection is lost=False setText('check internet') and when the connection become true setText('')
构造者
主代码
推荐答案
QThread不要太复杂,使用线程库:
Do not get complicated with QThread, use the threading library:
另一方面,由于您使用的是线程,因此不应从另一个线程更新 GUI,为此您可以使用 QMetaObject::invokeMethod
:
On the other hand, since you are using a thread, you should not update the GUI from another thread, for this you can use QMetaObject::invokeMethod
:
这篇关于如何使用 PyQt5 运行 while 循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!