Skip to content

GraphicsLayoutItemMixin

Sub classes

Name Children Inherits
GraphicsLayoutItem
prettyqt.widgets.graphicslayoutitem
Can be inherited to allow your custom items to be managed by layouts.
    GraphicsLayoutMixin
    prettyqt.widgets.graphicslayout
    GraphicsWidgetMixin
    prettyqt.widgets.graphicswidget

    🛈 DocStrings

    Bases: _GraphicsLayoutItemBase

    Source code in prettyqt/widgets/graphicslayoutitem.py
    class GraphicsLayoutItemMixin(_GraphicsLayoutItemBase):
        def __repr__(self):
            return get_repr(self)
    
        def __bool__(self):
            return not self.isEmpty()
    
        @functools.singledispatchmethod
        def set_size_policy(
            self,
            horizontal: widgets.sizepolicy.SizePolicyStr,
            vertical: widgets.sizepolicy.SizePolicyStr,
            control_type: widgets.sizepolicy.ControlTypeStr = "default",
        ):
            """Set the size policy.
    
            Args:
                horizontal: horizontal size policy
                vertical: vertical size policy
                control_type: control type associated with the widget
            """
            h_policy = widgets.sizepolicy.SIZE_POLICY[horizontal]
            v_policy = widgets.sizepolicy.SIZE_POLICY[vertical]
            c = widgets.sizepolicy.CONTROL_TYPE[control_type]
            self.setSizePolicy(h_policy, v_policy, c)
    
        @set_size_policy.register
        def _(self, policy: widgets.QSizePolicy):
            self.setSizePolicy(policy)
    
        def get_size_policy(self) -> widgets.SizePolicy:
            qpol = self.sizePolicy()
            return widgets.SizePolicy.clone(qpol)
    

    set_size_policy(horizontal: widgets.sizepolicy.SizePolicyStr, vertical: widgets.sizepolicy.SizePolicyStr, control_type: widgets.sizepolicy.ControlTypeStr = 'default')

    Set the size policy.

    Parameters:

    Name Type Description Default
    horizontal SizePolicyStr

    horizontal size policy

    required
    vertical SizePolicyStr

    vertical size policy

    required
    control_type ControlTypeStr

    control type associated with the widget

    'default'
    Source code in prettyqt/widgets/graphicslayoutitem.py
    @functools.singledispatchmethod
    def set_size_policy(
        self,
        horizontal: widgets.sizepolicy.SizePolicyStr,
        vertical: widgets.sizepolicy.SizePolicyStr,
        control_type: widgets.sizepolicy.ControlTypeStr = "default",
    ):
        """Set the size policy.
    
        Args:
            horizontal: horizontal size policy
            vertical: vertical size policy
            control_type: control type associated with the widget
        """
        h_policy = widgets.sizepolicy.SIZE_POLICY[horizontal]
        v_policy = widgets.sizepolicy.SIZE_POLICY[vertical]
        c = widgets.sizepolicy.CONTROL_TYPE[control_type]
        self.setSizePolicy(h_policy, v_policy, c)
    

    :fa-brands-github: Show source on GitHub