41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#!/usr/bin/python3
|
|
|
|
from PyQt6.QtCore import Qt
|
|
from PyQt6.QtGui import QFont
|
|
from PyQt6.QtWidgets import QSizePolicy, QGroupBox, QLabel, QProgressBar, QVBoxLayout
|
|
|
|
|
|
class BackgroundProcess(QGroupBox):
|
|
normal_font = QFont()
|
|
normal_font.setBold(False)
|
|
bold_font = QFont()
|
|
bold_font.setBold(True)
|
|
|
|
def __init__(self, title: str, parent=None, description: str="", steps: int=0):
|
|
super().__init__(title, parent)
|
|
|
|
self.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
|
|
self.setAlignment(Qt.AlignmentFlag.AlignLeading | Qt.AlignmentFlag.AlignVCenter)
|
|
self.setFont(self.bold_font)
|
|
|
|
self.layout = QVBoxLayout(self)
|
|
|
|
self.description = QLabel(description, self)
|
|
self.description.setFont(self.normal_font)
|
|
self.layout.addWidget(self.description)
|
|
|
|
self.progress_bar = QProgressBar(self)
|
|
self.progress_bar.setMaximum(steps)
|
|
self.layout.addWidget(self.progress_bar)
|
|
|
|
self.setLayout(self.layout)
|
|
|
|
def get_progress(self):
|
|
return 0
|
|
|
|
def set_range(self, maximum: int, minimum: int=0):
|
|
self.progress_bar.setRange(minimum, maximum)
|
|
|
|
def update_progress(self):
|
|
self.progress_bar.setValue(self.get_progress())
|
|
|