Skip to content

StatusBar

Base classes

Name Children Inherits
WidgetMixin
prettyqt.widgets.widget
QStatusBar
PySide6.QtWidgets
QStatusBar(self, /, parent: PySide6.QtWidgets.QWidget | None \= None, *, sizeGripEnabled: bool | None \= None) -> None

⋔ Inheritance diagram

graph TD
  102524033["widgets.StatusBar"]
  829357528["widgets.WidgetMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  625385617["gui.PaintDeviceMixin"]
  3362424026["QtWidgets.QStatusBar"]
  3620195106["QtWidgets.QWidget"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  673956333["QtGui.QPaintDevice"]
  829357528 --> 102524033
  3227531497 --> 829357528
  2751680898 --> 3227531497
  625385617 --> 829357528
  2751680898 --> 625385617
  2751680898 --> 829357528
  3362424026 --> 102524033
  3620195106 --> 3362424026
  3984060476 --> 3620195106
  37984305 --> 3984060476
  2751680898 --> 37984305
  673956333 --> 3620195106
  37984305 --> 673956333

🛈 DocStrings

Bases: WidgetMixin, QStatusBar

Horizontal bar suitable for presenting status information.

Source code in prettyqt/widgets/statusbar.py
class StatusBar(widgets.WidgetMixin, widgets.QStatusBar):
    """Horizontal bar suitable for presenting status information."""

    def __add__(self, other: QtGui.QAction | widgets.QWidget) -> StatusBar:
        match other:
            case QtGui.QAction():
                self.addAction(other)
                return self
            case widgets.QWidget():
                self.addWidget(other)
                return self
            case _:
                raise TypeError(other)

    def add_threadpool_info(self, threadpool: core.ThreadPool):
        class ThreadPoolLabel(widgets.Label):
            def update_job_count(self, num_jobs: int):
                text = f"Running jobs: {num_jobs}" if num_jobs > 0 else "No running jobs"
                self.set_text(text)

        status_label = ThreadPoolLabel(self)
        threadpool.job_num_updated.connect(status_label.update_job_count)
        status_label.update_job_count(threadpool.activeThreadCount())
        progress_bar = widgets.ProgressBar(self, text_visible=False)
        progress_bar.hide()
        progress_bar.setRange(0, 0)
        progress_bar.setFixedSize(200, 20)
        threadpool.busy_state_changed.connect(progress_bar.setVisible)
        self.addPermanentWidget(status_label)
        self.addPermanentWidget(progress_bar)

    def add_widget(self, widget: widgets.QWidget, permanent: bool = False) -> None:
        if permanent:
            self.addPermanentWidget(widget)
        else:
            self.addWidget(widget)

    def show_message(self, message: str, timeout: int = 0) -> None:
        self.showMessage(message, timeout)

:fa-brands-github: Show source on GitHub