2 Star 10 Fork 7

终點起點/PySide6-UI-Demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ProgressDialog.py 2.90 KB
一键复制 编辑 原始数据 按行查看 历史
终點起點 提交于 2024-08-23 16:48 +08:00 . 增加其他demo
import sys
import os
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *
class Demo(QWidget):
_step=0
dialog=None
customDialog=None
def __init__(self, parent=None):
super().__init__(parent)
self.parent = parent
layout = QVBoxLayout()
layout.setAlignment(Qt.AlignmentFlag.AlignTop)
btn=QPushButton('Show')
btn.clicked.connect(self.Show)
layout.addWidget(btn)
btn=QPushButton('ShowModal')
btn.clicked.connect(self.ShowModal)
layout.addWidget(btn)
btn=QPushButton('ShowAuto')
btn.clicked.connect(self.ShowAuto)
layout.addWidget(btn)
btn=QPushButton('ShowCustom')
btn.clicked.connect(self.ShowCustom)
layout.addWidget(btn)
self.timer=QTimer(self)
self.timer.setInterval(1000)
self.timer.timeout.connect(self.OnTimer)
self.setLayout(layout)
def Show(self):
self.dialog=QProgressDialog('Normal Progress','取消',0,100,self)
#self.dialog.setWindowTitle('Normal')
#self.dialog.setLabelText('Normal Progress')
#self.dialog.setCancelButtonText('取消')
#self.dialog.setMinimum(0)
#self.dialog.setMaximum(100)
self.dialog.canceled.connect(self.OnStop)
self.timer.start()
def ShowModal(self):
self.dialog=QProgressDialog('Modal Progress','停止',0,100,self)
self.dialog.setWindowModality(Qt.WindowModality.WindowModal)
self.dialog.canceled.connect(self.OnStop)
self.timer.start()
def ShowAuto(self):
self.dialog=QProgressDialog('Auto Progress','停止',0,100,self)
self.dialog.setWindowModality(Qt.WindowModality.WindowModal)
self.dialog.setAutoClose(False)#取消满值自动关闭(默认100%自动关闭)
self.dialog.setAutoReset(False)#取消自动重置(默认100%自动重置)
self.dialog.canceled.connect(self.OnStop)
self.timer.start()
def ShowCustom(self):
self.customDialog=QProgressDialog('Custom Progress','Stop',0,100,self)
self.customDialog.setWindowModality(Qt.WindowModality.WindowModal)
self.custombar=QProgressBar()
self.custombar.setMinimum(0)
self.custombar.setMaximum(100)
self.custombar.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.customDialog.setBar(self.custombar)
self.customDialog.canceled.connect(self.OnStop)
self.timer.start()
def OnTimer(self):
if self.dialog is not None:
self.dialog.setValue(self._step)
if self.customDialog is not None:
self.custombar.setValue(self._step)
self._step+=1
def OnStop(self):
self.timer.stop()
self.dialog=None
self.customDialog=None
self._step=0
def runDemo(parent):
wigdet = Demo(parent)
return wigdet
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/johnjiangw/pyside6-ui-demo.git
git@gitee.com:johnjiangw/pyside6-ui-demo.git
johnjiangw
pyside6-ui-demo
PySide6-UI-Demo
master

搜索帮助