Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)))
def __init__(self):
self._solver = kiwi.Solver()
self._edit_stack = []
self._initialized = False
self._running = False
"""
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,