添加 ProgressInfoBar 组件
This commit is contained in:
45
ui/pyui/test_ui.py
Normal file
45
ui/pyui/test_ui.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QVBoxLayout
|
||||
from qfluentwidgets import PushButton, InfoBarIcon, InfoBarPosition
|
||||
|
||||
from ui.components.infobar import ProgressInfoBar
|
||||
from ui.components.widget import Widget
|
||||
|
||||
|
||||
class TestWidget(Widget):
|
||||
def __init__(self, key: str, parents=None):
|
||||
super().__init__(key, parents)
|
||||
|
||||
self.button = PushButton('测试按钮')
|
||||
self.vbox = QVBoxLayout(self)
|
||||
|
||||
self.vbox.addWidget(self.button)
|
||||
self.vbox.addStretch(1)
|
||||
|
||||
self.pib = ProgressInfoBar(
|
||||
icon=InfoBarIcon.INFORMATION,
|
||||
title='请稍后',
|
||||
content="",
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=False,
|
||||
position=InfoBarPosition.BOTTOM,
|
||||
duration=-1,
|
||||
parent=self
|
||||
)
|
||||
|
||||
self.p = -20
|
||||
|
||||
self.button.clicked.connect(self.add_progress)
|
||||
|
||||
def add_progress(self):
|
||||
self.p += 10
|
||||
self.pib.setVisible(True)
|
||||
self.pib.set_progress(self.p)
|
||||
if 0 <= self.p <= 100:
|
||||
self.pib.set_title('正在制作')
|
||||
elif 100 <= self.p <= 110:
|
||||
self.pib.set_title('请稍后')
|
||||
elif self.p > 110:
|
||||
self.pib.show_success()
|
||||
self.p = -20
|
||||
self.pib.set_title('正在等待')
|
||||
Reference in New Issue
Block a user