enaml.core.looper

Classes

Looper A pattern object that repeats its children over an iterable.
class enaml.core.looper.Looper(parent=None, **kwargs)[source]

Bases: enaml.core.pattern.Pattern

A pattern object that repeats its children over an iterable.

The children of a Looper are used as a template when creating new objects for each item in the given iterable. Each iteration of the loop will be given an indenpendent scope which is the union of the outer scope and any identifiers created during the iteration. This scope will also contain loop_index and loop_item variables which are the index and value of the iterable, respectively.

All items created by the looper will be added as children of the parent of the Looper. The Looper keeps ownership of all items it creates. When the iterable for the looper is changed, the looper will only create and destroy children for the items in the iterable which have changed.

iterable

The iterable to use when creating the items for the looper.

items

The list of items created by the conditional. Each item in the list represents one iteration of the loop and is a list of the items generated during that iteration. This list should not be manipulated directly by user code.

destroy()[source]

A reimplemented destructor.

The looper will release the owned items on destruction.

pattern_items()[source]

Get a list of items created by the pattern.

refresh_items()[source]

Refresh the items of the pattern.

This method destroys the old items and creates and initializes the new items.