Skip to content

ProgressBar

Base classes

Name Children Inherits
WidgetMixin
prettyqt.widgets.widget
QProgressBar
PySide6.QtWidgets
QProgressBar(self, /, parent: PySide6.QtWidgets.QWidget | None \= None, *, minimum: int | None \= None, maximum: int | None \= None, text: str | None \= None, value: int | None \= None, alignment: PySide6.QtCore.Qt.AlignmentFlag | None \= None, textVisible: bool | None \= None, orientation: PySide6.QtCore.Qt.Orientation | None \= None, invertedAppearance: bool | None \= None, textDirection: PySide6.QtWidgets.QProgressBar.Direction | None \= None, format: str | None \= None) -> None

â‹” Inheritance diagram

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

🛈 DocStrings

Bases: WidgetMixin, QProgressBar

Horizontal or vertical progress bar.

Source code in prettyqt/widgets/progressbar.py
class ProgressBar(widgets.WidgetMixin, widgets.QProgressBar):
    """Horizontal or vertical progress bar."""

    def __init__(self, *args, text_visible: bool = True, **kwargs):
        self._text_direction = widgets.QProgressBar.Direction.TopToBottom
        super().__init__(*args, text_visible=text_visible, **kwargs)

    def set_alignment(self, alignment: constants.AlignmentStr | constants.AlignmentFlag):
        """Set the alignment of the layout.

        Args:
            alignment: alignment for the layout
        """
        self.setAlignment(constants.ALIGNMENTS.get_enum_value(alignment))

    def get_alignment(self) -> constants.AlignmentStr:
        """Return current alignment.

        Returns:
            alignment
        """
        return constants.ALIGNMENTS.inverse[self.alignment()]

    def set_text_direction(
        self, text_direction: TextDirectionStr | widgets.QProgressBar.Direction
    ):
        """Set the text direction of the layout.

        Args:
            text_direction: text direction for the layout
        """
        val = TEXT_DIRECTIONS.get_enum_value(text_direction)
        self._text_direction = val
        self.setTextDirection(val)

    def get_text_direction(self) -> TextDirectionStr:
        """Return current text direction.

        Returns:
            Text direction
        """
        direction = (
            self.textDirection()
            if hasattr(self, "textDirection")
            else self._text_direction
        )
        return TEXT_DIRECTIONS.inverse[direction]

    def set_orientation(
        self, orientation: constants.OrientationStr | constants.Orientation
    ):
        """Set the orientation of the progress bar.

        Args:
            orientation: orientation for the progress bar
        """
        self.setOrientation(constants.ORIENTATION.get_enum_value(orientation))

    def get_orientation(self) -> constants.OrientationStr:
        """Return current orientation.

        Returns:
            orientation
        """
        return constants.ORIENTATION.inverse[self.orientation()]

    def set_range(self, start: int, end: int):
        self.setRange(start, end)

    def set_value(self, value: int):
        self.setValue(value)

    def get_value(self) -> int:
        return self.value()

get_alignment() -> constants.AlignmentStr

Return current alignment.

Source code in prettyqt/widgets/progressbar.py
def get_alignment(self) -> constants.AlignmentStr:
    """Return current alignment.

    Returns:
        alignment
    """
    return constants.ALIGNMENTS.inverse[self.alignment()]

get_orientation() -> constants.OrientationStr

Return current orientation.

Source code in prettyqt/widgets/progressbar.py
def get_orientation(self) -> constants.OrientationStr:
    """Return current orientation.

    Returns:
        orientation
    """
    return constants.ORIENTATION.inverse[self.orientation()]

get_text_direction() -> TextDirectionStr

Return current text direction.

Source code in prettyqt/widgets/progressbar.py
def get_text_direction(self) -> TextDirectionStr:
    """Return current text direction.

    Returns:
        Text direction
    """
    direction = (
        self.textDirection()
        if hasattr(self, "textDirection")
        else self._text_direction
    )
    return TEXT_DIRECTIONS.inverse[direction]

set_alignment(alignment: constants.AlignmentStr | constants.AlignmentFlag)

Set the alignment of the layout.

Parameters:

Name Type Description Default
alignment AlignmentStr | AlignmentFlag

alignment for the layout

required
Source code in prettyqt/widgets/progressbar.py
def set_alignment(self, alignment: constants.AlignmentStr | constants.AlignmentFlag):
    """Set the alignment of the layout.

    Args:
        alignment: alignment for the layout
    """
    self.setAlignment(constants.ALIGNMENTS.get_enum_value(alignment))

set_orientation(orientation: constants.OrientationStr | constants.Orientation)

Set the orientation of the progress bar.

Parameters:

Name Type Description Default
orientation OrientationStr | Orientation

orientation for the progress bar

required
Source code in prettyqt/widgets/progressbar.py
def set_orientation(
    self, orientation: constants.OrientationStr | constants.Orientation
):
    """Set the orientation of the progress bar.

    Args:
        orientation: orientation for the progress bar
    """
    self.setOrientation(constants.ORIENTATION.get_enum_value(orientation))

set_text_direction(text_direction: TextDirectionStr | widgets.QProgressBar.Direction)

Set the text direction of the layout.

Parameters:

Name Type Description Default
text_direction TextDirectionStr | Direction

text direction for the layout

required
Source code in prettyqt/widgets/progressbar.py
def set_text_direction(
    self, text_direction: TextDirectionStr | widgets.QProgressBar.Direction
):
    """Set the text direction of the layout.

    Args:
        text_direction: text direction for the layout
    """
    val = TEXT_DIRECTIONS.get_enum_value(text_direction)
    self._text_direction = val
    self.setTextDirection(val)

:fa-brands-github: Show source on GitHub