Skip to content

PopupInfo

Qt Base Class: QDialog

Signature: QDialog(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None

Base classes

Name Children Inherits
Dialog
prettyqt.widgets.dialog

⋔ Inheritance diagram

graph TD
  1473367130176["custom_widgets.PopupInfo"]
  1473296197328["widgets.Dialog"]
  1473296195376["widgets.DialogMixin"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473241356416["QtWidgets.QDialog"]
  1473290849680["QtWidgets.QWidget"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473300082368["QtGui.QPaintDevice"]
  1473296197328 --> 1473367130176
  1473296195376 --> 1473296197328
  1473293688240 --> 1473296195376
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480
  1473241356416 --> 1473296197328
  1473290849680 --> 1473241356416
  1473288842240 --> 1473290849680
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208
  1473300082368 --> 1473290849680
  1473291690208 --> 1473300082368

🛈 DocStrings

Bases: Dialog

Dialog overlay to show some info to user.

Source code in prettyqt\custom_widgets\popupinfo.py
class PopupInfo(widgets.Dialog):
    """Dialog overlay to show some info to user."""

    _singleton: PopupInfo | None = None

    def __init__(self, parent: widgets.QWidget | None = None, text: str | None = None):
        super().__init__(parent=parent)
        self.timer = core.Timer(single_shot=True, timeout=self.close)
        self.label = widgets.Label(alignment="center")
        self.iconlabel = widgets.Label()
        self.set_icon("mdi.information")
        self.set_flags(stay_on_top=True, frameless=True, tooltip=True)
        layout = self.set_layout("horizontal", margin=20, size_constraint="minimum")
        self.set_background_color("black")
        self.label.set_color("white")
        layout.add(self.iconlabel)
        layout.add(self.label)
        self.hide()

    def set_text_color(self, color: datatypes.ColorType):
        self.label.set_color(color)

    def set_icon(self, icon: datatypes.IconType):
        pixmap = iconprovider.get_icon(icon, color="white").pixmap(32)
        self.iconlabel.setPixmap(pixmap)

    def show_popup(
        self,
        text: str,
        icon: datatypes.IconType = "mdi.information",
        text_color: datatypes.ColorType = "white",
        background_color: datatypes.ColorType = "black",
        position="screen",
        timeout: int = 2500,
    ):
        self.set_background_color(background_color)
        self.label.set_color(text_color)
        self.label.setText(text)
        self.set_icon(icon)
        self.adjustSize()
        self.position_on(position, y_offset=-200)
        self.timer.start(timeout)
        self.show()

    @classmethod
    def popup(
        cls,
        text: str,
        icon: datatypes.IconType = "mdi.information",
        text_color: datatypes.ColorType = "white",
        background_color: datatypes.ColorType = "black",
        position="screen",
        timeout: int = 2500,
    ):
        if cls._singleton is None:
            cls._singleton = cls()
        popup = cls._singleton
        popup.set_background_color(background_color)
        popup.label.set_color(text_color)
        popup.label.setText(text)
        popup.set_icon(icon)
        popup.adjustSize()
        popup.position_on(position, y_offset=-200)
        popup.timer.start(timeout)
        popup.show()

⌗ Property table

Qt Property Type Doc
objectName QString
modal bool
windowModality Qt::WindowModality
enabled bool
geometry QRect
frameGeometry QRect
normalGeometry QRect
x int
y int
pos QPoint
frameSize QSize
size QSize
width int
height int
rect QRect
childrenRect QRect
childrenRegion QRegion
sizePolicy QSizePolicy
minimumSize QSize
maximumSize QSize
minimumWidth int
minimumHeight int
maximumWidth int
maximumHeight int
sizeIncrement QSize
baseSize QSize
palette QPalette
font QFont
cursor QCursor
mouseTracking bool
tabletTracking bool
isActiveWindow bool
focusPolicy Qt::FocusPolicy
focus bool
contextMenuPolicy Qt::ContextMenuPolicy
updatesEnabled bool
visible bool
minimized bool
maximized bool
fullScreen bool
sizeHint QSize
minimumSizeHint QSize
acceptDrops bool
windowTitle QString
windowIcon QIcon
windowIconText QString
windowOpacity double
windowModified bool
toolTip QString
toolTipDuration int
statusTip QString
whatsThis QString
accessibleName QString
accessibleDescription QString
layoutDirection Qt::LayoutDirection
autoFillBackground bool
styleSheet QString
locale QLocale
windowFilePath QString
inputMethodHints QFlags
sizeGripEnabled bool
modal bool