Skip to content

LayoutItemMixin

Subclasses

Class Module Description
LayoutItem prettyqt.widgets.layoutitem
WidgetItem prettyqt.widgets.widgetitem
LayoutMixin prettyqt.widgets.layout
SpacerItem prettyqt.widgets.spaceritem

⋔ Inheritance diagram

graph TD
  1473296346656["widgets.LayoutItemMixin"]
  140713234304496["builtins.object"]
  140713234304496 --> 1473296346656

🛈 DocStrings

Source code in prettyqt\widgets\layoutitem.py
class LayoutItemMixin:
    def __bool__(self):
        return not self.isEmpty()

    def set_alignment(self, alignment: constants.AlignmentStr):
        """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 get_item(
        self,
    ) -> widgets.QWidget | widgets.QLayout | widgets.QSpacerItem | None:
        if content := self.widget():
            return content
        if content := self.layout():
            return content
        return content if (content := self.spacerItem()) else None

    def get_control_types(self) -> list[widgets.sizepolicy.ControlTypeStr]:
        return widgets.sizepolicy.CONTROL_TYPE.get_list(self.controlTypes())

    def get_expanding_directions(self) -> list[constants.OrientationStr]:
        return constants.ORIENTATION.get_list(self.expandingDirections())

get_alignment() -> constants.AlignmentStr

Return current alignment.

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

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

set_alignment(alignment: constants.AlignmentStr)

Set the alignment of the layout.

Parameters:

Name Type Description Default
alignment AlignmentStr

alignment for the layout

required
Source code in prettyqt\widgets\layoutitem.py
def set_alignment(self, alignment: constants.AlignmentStr):
    """Set the alignment of the layout.

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