Skip to content

LayoutItemMixin

Sub classes

Name Children Inherits
LayoutItem
prettyqt.widgets.layoutitem
Abstract item that a QLayout manipulates.
    WidgetItem
    prettyqt.widgets.widgetitem
    Layout item that represents a widget.
      LayoutMixin
      prettyqt.widgets.layout
      SpacerItem
      prettyqt.widgets.spaceritem
      Blank space in a layout.

        🛈 DocStrings

        Bases: _LayoutItemBase

        Source code in prettyqt/widgets/layoutitem.py
        class LayoutItemMixin(_LayoutItemBase):
            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))
        

        :fa-brands-github: Show source on GitHub