from PyQt5 import QtCore, QtWidgets, QtGui
import qtawesome as qta
class overlay(QtWidgets.QWidget):
def __init__(self, parent=None):
super(overlay, self).__init__(parent)
self.parent = parent
child_alignmenet = QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop
layout = QtWidgets.QVBoxLayout()
self.spin_widget = qta.IconWidget()
self.progress_text = QtWidgets.QLabel()
font = QtGui.QFont()
font.setPointSize(12)
self.progress_text.setFont(font)
self.progress_text.setAlignment(child_alignmenet)
self.progress_bar = QtWidgets.QProgressBar()
self.progress_bar.setFixedWidth(220)
self.progress_bar.setAlignment(child_alignmenet)
spin_icon = qta.icon('mdi.loading', color='blue',
animation=qta.Spin(self.spin_widget, step=25))
self.spin_widget.setIcon(spin_icon)
self.spin_widget.setIconSize(QtCore.QSize(96, 96))
self.spin_widget.setAlignment(child_alignmenet)
layout.addWidget(self.spin_widget)
layout.addWidget(self.progress_text)
layout.addWidget(self.progress_bar)
layout.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.setLayout(layout)
def update_text(self,text):
self.progress_text.setText(text)
def update_progress(self, value):
self.progress_bar.setValue(value)
def paintEvent(self, event):
painter = QtGui.QPainter()
painter.begin(self)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.fillRect(event.rect(), QtGui.QBrush(QtGui.QColor(255, 255, 255, 127)))