class MessageDialog(QDialog): def __init__(self, parent = None): QDialog.__init__(self, parent) self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) self.layout = QVBoxLayout(self) self.label = ScaledLabel() self.label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.layout.addWidget(self.label) self.timer = QTimer() self.timer.timeout.connect(self.hide) self.timer.setSingleShot(True) def showMessage(self, message): self.label.setText(message) self.show() self.raise_() def showMessageTimed(self, message, timeout = 3000): self.showMessage(message) self.timer.start(timeout)
class MessageOverlay(Overlay): def __init__(self, keyPressHandler, parent=None): Overlay.__init__(self, keyPressHandler, parent) self.layout = QVBoxLayout(self) self.message = ScaledLabel() self.message.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.message.setAttribute(Qt.WA_TranslucentBackground) self.layout.addWidget(self.message) def setMessage(self, message): self.message.setText(message)