How to use the kiwisolver.strength.medium function in kiwisolver

To help you get started, we’ve selected a few kiwisolver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nucleic / enaml / enaml / layout / layout_manager.py View on Github external
----------
        items : list
            A list of LayoutItem instances for the system. The root
            item should *not* be included in this list.

        """
        # Reset the state of the solver.
        del self._edit_stack
        del self._layout_items
        solver = self._solver
        solver.reset()

        # Setup the standard edit variables.
        root = self._root_item
        d = root.constrainable()
        strength = kiwi.strength.medium
        pairs = ((d.width, strength), (d.height, strength))
        self._push_edit_vars(pairs)

        # Generate the constraints for the layout system. The size hint
        # and bounds of the root item are ignored since the input to the
        # solver is the suggested size of the root item and the output
        # of the solver is used to compute the bounds of the item.
        cns = []
        hc = root.hard_constraints()
        mc = root.margin_constraints()
        lc = root.layout_constraints()
        root._margin_cache = mc
        cns.extend(hc)
        cns.extend(mc)
        cns.extend(lc)
        for child in items:
github nucleic / enaml / enaml / layout / spacers.py View on Github external
def constraints(self, first, second):
        """ A constraint of the form: (second - first) >= size

        """
        return [(second - first) >= self.size]


class FlexSpacer(Spacer):
    """ A spacer with a hard minimum and a preference for that minimum.

    """
    #: The strength for the minimum space constraint.
    min_strength = StrengthMember(kiwi.strength.required)

    #: The strength for the equality space constraint.
    eq_strength = StrengthMember(kiwi.strength.medium * 1.25)

    def __init__(self, size, min_strength=None, eq_strength=None):
        """ Initialize a FlexSpacer.

        Parameters
        ----------
        size : int
            The basic size of the spacer, in pixels >= 0.

        min_strength : strength-like, optional
            The strength to apply to the minimum spacer size. The
            default is kiwi.strength.required.

        eq_strength : strength-like, optional
            The strength to apply to preferred spacer size. The
            default is 1.25 * kiwi.strength.medium.
github enthought / enable / enable / layout / layout_manager.py View on Github external
    def layout(self, cb, width, height, size, strength=kiwi.strength.medium):
        """ Perform an iteration of the solver for the new width and
        height constraint variables.

        Parameters
        ----------
        cb : callable
            A callback which will be called when new values from the
            solver are available. This will be called from within a
            solver context while the solved values are valid. Thus
            the new values should be consumed before the callback
            returns.

        width : Constraint Variable
            The constraint variable representing the width of the
            main layout container.

kiwisolver

A fast implementation of the Cassowary constraint solver

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

89 / 100
Full package analysis

Similar packages