class PMessageBox(PAbstractBox): # STYLE SHEET STYLE = """color:white;font-size:16pt;""" OUT_POS = MIDCENTER IN_POS = MIDCENTER STOP_POS = MIDCENTER def __init__(self, parent): PAbstractBox.__init__(self, parent) self.ui = Ui_MessageBox() self.ui.setupUi(self) self.busy = QProgressIndicator(self, "white") self.busy.setMinimumSize(QSize(32, 32)) self.busy.hide() self.ui.mainLayout.insertWidget(1, self.busy) self._animation = 2 self._duration = 1 self.last_msg = None self.setStyleSheet(PMessageBox.STYLE) self.enableOverlay() self.setOverlayOpacity(150) self.hide() def showMessage(self, message, icon=None, busy=False): self.ui.label.setText(message) if busy: self.busy.busy() self.ui.icon.hide() else: if icon: if type(icon) == str: icon = KIcon(icon).pixmap(32, 32) self.ui.icon.setPixmap(QPixmap(icon)) self.ui.icon.show() else: self.ui.icon.hide() self.busy.hide() self.last_msg = self.animate(start=PMessageBox.IN_POS, stop=PMessageBox.STOP_POS) qApp.processEvents() # ??? def hideMessage(self, force=False): if self.isVisible() or force: self.animate(start=PMessageBox.STOP_POS, stop=PMessageBox.OUT_POS, direction=OUT, dont_animate=True)
class PMessageBox(PAbstractBox): # STYLE SHEET STYLE = """color:white;font-size:16pt;""" OUT_POS = MIDCENTER IN_POS = MIDCENTER STOP_POS = MIDCENTER def __init__(self, parent): PAbstractBox.__init__(self, parent) self.ui = Ui_MessageBox() self.ui.setupUi(self) self.busy = QProgressIndicator(self, "white") self.busy.setMinimumSize(QtCore.QSize(32, 32)) self.busy.hide() self.ui.mainLayout.insertWidget(1, self.busy) self._animation = 2 self._duration = 1 self.last_msg = None self.setStyleSheet(PMessageBox.STYLE) self.enableOverlay() self.setOverlayOpacity(150) self.hide() def showMessage(self, message, icon = None, busy = False): self.ui.label.setText(message) if busy: self.busy.busy() self.ui.icon.hide() else: if icon: if type(icon) == str: icon = QIcon(icon).pixmap(32,32) self.ui.icon.setPixmap(QtGui.QPixmap(icon)) self.ui.icon.show() else: self.ui.icon.hide() self.busy.hide() self.last_msg = self.animate(start = PMessageBox.IN_POS, stop = PMessageBox.STOP_POS) QtWidgets.qApp.processEvents() def hideMessage(self, force = False): if self.isVisible() or force: self.animate(start = PMessageBox.STOP_POS, stop = PMessageBox.OUT_POS, direction = OUT, dont_animate = True)
def __init__(self, parent): PAbstractBox.__init__(self, parent) self.ui = Ui_MessageBox() self.ui.setupUi(self) self.busy = QProgressIndicator(self, "white") self.busy.setMinimumSize(QtCore.QSize(32, 32)) self.busy.hide() self.ui.mainLayout.insertWidget(1, self.busy) self._animation = 2 self._duration = 500 self.last_msg = None self.setStyleSheet(PMessageBox.STYLE) self.enableOverlay() self.hide()