4 Star 21 Fork 9

木子/PyQt_practice

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
04-QProgressBar-信号.py 775 Bytes
一键复制 编辑 原始数据 按行查看 历史
木子 提交于 2022-02-21 20:53 +08:00 . Reformat code with isort
import sys
from PyQt5.Qt import *
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("QProgressBar")
self.resize(500, 500)
self.move(400, 250)
self.setup_ui()
def setup_ui(self):
pb = QProgressBar(self)
pb.move(100, 100)
timer = QTimer(pb)
def change_progress():
if pb.value() == pb.maximum():
timer.stop()
pb.setValue(pb.value() + 1)
timer.timeout.connect(change_progress)
timer.start(500)
pb.valueChanged.connect(lambda val: print(f"当前进度值为{val}"))
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/muzing/PyQt_practice.git
git@gitee.com:muzing/PyQt_practice.git
muzing
PyQt_practice
PyQt_practice
master

搜索帮助