enaml.widgets.constraints_widget

Classes

ConstraintsWidget

A Widget subclass which adds constraint information.

class enaml.widgets.constraints_widget.ConstraintsWidget(parent=None, **kwargs)[source]

Bases: Widget, ConstrainableMixin

A Widget subclass which adds constraint information.

A ConstraintsWidget is augmented with symbolic constraint variables which define a box model on the widget. This box model is used to declare constraints between this widget and other components which participate in constraints-based layout.

Constraints are added to a widget by assigning a list to the ‘constraints’ attribute. This list may contain raw Constraint objects, which are created by manipulating the symbolic constraint variables, or ConstraintHelper objects which generate Constraint objects on request.

constraints

The list of user-specified constraints or ConstraintHelpers.

hug_width

How strongly a widget hugs it’s width hint. This is equivalent to the constraint:

(width == hint) | hug_width
hug_height

How strongly a widget hugs it’s height hint. This is equivalent to the constraint:

(height == hint) | hug_height
resist_width

How strongly a widget resists clipping its width hint. This is equivalent to the constraint:

(width >= hint) | resist_width

resist_height

How strongly a widget resists clipping its height hint. This is equivalent to the constraint:

(height >= hint) | resist_height
limit_width

How strongly a widget resists expanding its width hint. This is equivalent to the constraint:

(width <= hint) | limit_width
limit_height

How strongly a widget resists expanding its height hint. This is equivalent to the constraint:

(height <= hint) | limit_height
proxy

A reference to the ProxyConstraintsWidget object.

request_relayout()[source]

Request a relayout from the proxy widget.

This will invoke the ‘request_relayout’ method on an active proxy. The proxy should collapse the requests as necessary.

when(switch)[source]

A method which returns self or None based on the truthness of the argument.

This can be useful to easily turn off the effects of an object in constraints-based layout.

Parameters:

switch (bool) – A boolean which indicates whether this instance or None should be returned.

Returns:

result – If ‘switch’ is boolean True, self is returned. Otherwise, None is returned.

Return type:

self or None

layout_constraints()[source]

Get the constraints to use for this component’s layout.

This method may be overridden by subclasses as needed to create custom constraints. It will be called when the relayout request has been made by the layout engine. The default implementation will return the list of ‘constraints’ defined by the user.

activated

An event fired when an object’s proxy is activated. It is triggered once during the object lifetime, at the end of the activate_proxy method.

background

The background color of the widget.

destroyed

An event fired when an object has been destroyed. It is triggered once during the object lifetime, just before the object is removed from the tree structure.

enabled

Whether or not the widget is enabled.

initialized

An event fired when an object is initialized. It is triggered once during the object lifetime, at the end of the initialize method.

name

Export the ‘name’ attribute as a declarative member.

style_class

The style class to which this item belongs. Multiple classes can be separated with whitespace. An empty string indicates the widget does not belong to any style class.

visible

Whether or not the widget is visible.