mirror of
https://github.com/283375/arcaea-offline-ocr-model.git
synced 2025-04-11 09:10:17 +00:00
feat: BlockLabelDialog
This commit is contained in:
parent
01b8b2e26c
commit
0ae960a405
38
ui/components/blockLabelDialog.py
Normal file
38
ui/components/blockLabelDialog.py
Normal file
@ -0,0 +1,38 @@
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication, QLabel
|
||||
|
||||
|
||||
class BlockLabelDialog(QLabel):
|
||||
def __init__(
|
||||
self,
|
||||
parent=None,
|
||||
modality: Qt.WindowModality = Qt.WindowModality.ApplicationModal,
|
||||
*,
|
||||
autoShow: bool = False
|
||||
):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setWindowFlag(Qt.WindowType.Dialog, True)
|
||||
self.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, False)
|
||||
self.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint, False)
|
||||
self.setWindowFlag(Qt.WindowType.WindowCloseButtonHint, False)
|
||||
self.setWindowModality(modality)
|
||||
self.setWindowTitle("Please Wait")
|
||||
self.setMinimumWidth(200)
|
||||
self.setMargin(20)
|
||||
self.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.autoShow = autoShow
|
||||
|
||||
def show(self):
|
||||
super().show()
|
||||
QApplication.processEvents()
|
||||
|
||||
def __enter__(self):
|
||||
if self.autoShow:
|
||||
self.show()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.close()
|
||||
self.deleteLater()
|
@ -7,6 +7,7 @@ from PySide6.QtWidgets import QLabel, QWidget
|
||||
|
||||
from project import Project
|
||||
|
||||
from .blockLabelDialog import BlockLabelDialog
|
||||
from .projectEntry_Classify_ui import Ui_ProjectEntry_Classify
|
||||
|
||||
|
||||
@ -89,4 +90,8 @@ class ProjectEntry_Classify(Ui_ProjectEntry_Classify, QWidget):
|
||||
|
||||
@Slot()
|
||||
def on_loadSamplesButton_clicked(self):
|
||||
self.samplesListWidget.setSamples(self.project.samplesUnclassified)
|
||||
with BlockLabelDialog(self) as block:
|
||||
block.setText(f"{self.project.name}<br>Loading unclassified samples")
|
||||
block.show()
|
||||
|
||||
self.samplesListWidget.setSamples(self.project.samplesUnclassified)
|
||||
|
@ -1,8 +1,9 @@
|
||||
from PySide6.QtCore import Qt, Signal, Slot
|
||||
from PySide6.QtWidgets import QApplication, QLabel, QWidget
|
||||
from PySide6.QtWidgets import QApplication, QWidget
|
||||
|
||||
from project import Project
|
||||
|
||||
from .blockLabelDialog import BlockLabelDialog
|
||||
from .projectEntry_Manage_ui import Ui_ProjectEntry_Manage
|
||||
from .yieldProgress import YieldProgress
|
||||
|
||||
@ -26,31 +27,24 @@ class ProjectEntry_Manage(Ui_ProjectEntry_Manage, QWidget):
|
||||
self.projectDescriptionLabel.setText("-")
|
||||
return
|
||||
|
||||
blockLabel = QLabel(self)
|
||||
blockLabel.setWindowModality(Qt.WindowModality.ApplicationModal)
|
||||
blockLabel.setWindowFlag(Qt.WindowType.Dialog, True)
|
||||
blockLabel.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, False)
|
||||
blockLabel.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint, False)
|
||||
blockLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
blockLabel.setText(f"Loading project<br>{self.project.name}")
|
||||
blockLabel.setMargin(20)
|
||||
blockLabel.show()
|
||||
QApplication.processEvents()
|
||||
self.projectNameLabel.setText(self.project.name)
|
||||
self.projectDescriptionLabel.setText(
|
||||
"<br>".join(
|
||||
[
|
||||
str(self.project.path.resolve()),
|
||||
f"{len(self.project.sources)} sources",
|
||||
f"{len(self.project.samples)} samples",
|
||||
f"- {len(self.project.samplesClassified)} classified",
|
||||
f"- {len(self.project.samplesIgnored)} ignored",
|
||||
f"- {len(self.project.samplesUnclassified)} unclassified",
|
||||
]
|
||||
with BlockLabelDialog(self) as block:
|
||||
block.setText(f"{self.project.name}<br>Updating status")
|
||||
block.show()
|
||||
|
||||
QApplication.processEvents()
|
||||
self.projectNameLabel.setText(self.project.name)
|
||||
self.projectDescriptionLabel.setText(
|
||||
"<br>".join(
|
||||
[
|
||||
str(self.project.path.resolve()),
|
||||
f"{len(self.project.sources)} sources",
|
||||
f"{len(self.project.samples)} samples",
|
||||
f"- {len(self.project.samplesClassified)} classified",
|
||||
f"- {len(self.project.samplesIgnored)} ignored",
|
||||
f"- {len(self.project.samplesUnclassified)} unclassified",
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
blockLabel.close()
|
||||
blockLabel.deleteLater()
|
||||
|
||||
@Slot()
|
||||
def on_updateButton_clicked(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user