4 Star 21 Fork 9

木子/PyQt_practice

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
01-QProgressDialog-创建.py 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
木子 提交于 2022-02-21 20:53 +08:00 . Reformat code with isort
import sys
from time import sleep
from PyQt5.Qt import *
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("QProgressDialog")
self.resize(500, 500)
self.move(400, 250)
self.setup_ui()
def setup_ui(self):
# pd = QProgressDialog(self) # 默认等待4秒后弹出,若在4秒内进度条走完,则不弹出显示
pd = QProgressDialog("说明性文字", "取消按钮的文字", 1, 1000, self) # 两个int为进度条范围
pd.setAutoClose(False) # 进度条走完后是否自动关闭,默认值为True
pd.setAutoReset(False) # 进度条走完后是否自动重置,默认值为True
pd.open(lambda: print("对话框被取消")) # 窗口级别模态窗口
# pd.show() # 非模态
pd.setMinimumDuration(0) # 设置最小等待时间
# pd.setValue(50)
for i in range(1, 101):
# sleep(1) # 简易测试,会导致程序卡死
pd.setValue(i)
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

搜索帮助