How to use the kiwisolver.Solver 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 / workbench / ui / menu_helper.py View on Github external
if before:
            if before not in variables:
                msg = "item '%s' has invalid `before` reference '%s'"
                raise ValueError(msg % (node.path, before))
            target_var = variables[before]
            constraints.append((this_var + 0.1 <= target_var) | 'strong')
        after = node.item.after
        if after:
            if after not in variables:
                msg = "item '%s' has invalid `after` reference '%s'"
                raise ValueError(msg % (node.path, after))
            target_var = variables[after]
            constraints.append((target_var + 0.1 <= this_var) | 'strong')
        prev_var = this_var

    solver = kiwi.Solver()
    for cn in constraints:
        solver.addConstraint(cn)
    solver.updateVariables()

    return sorted(nodes, key=lambda node: (variables[node.id].value(), id(node)))
github enthought / enable / enable / layout / layout_manager.py View on Github external
def __init__(self):
        self._solver = kiwi.Solver()
        self._edit_stack = []
        self._initialized = False
        self._running = False
github nucleic / enaml / enaml / layout / layout_manager.py View on Github external
"""
        raise NotImplementedError


class LayoutManager(Atom):
    """ A class which manages the layout for a system of items.

    This class is used by the various in-process backends to simplify
    the task of implementing constraint layout management.

    """
    #: The primary layout item which owns the layout.
    _root_item = Typed(LayoutItem)

    #: The solver used by the layout manager.
    _solver = Typed(kiwi.Solver, ())

    #: The stack of edit variables added to the solver.
    _edit_stack = List()

    #: The list of layout items handled by the manager.
    _layout_items = List()

    def __init__(self, item):
        """ Initialize a LayoutManager.

        Parameters
        ----------
        item : LayoutItem
            The layout item which contains the widget which is the
            root of the layout system. This item is the conceptual
            owner of the system. It is not resized by the manager,

kiwisolver

A fast implementation of the Cassowary constraint solver

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

91 / 100
Full package analysis

Similar packages