Looper¶
No example available.
Declaration¶
- class enaml.core.looper.Looper(parent=None, **kwargs)[source]¶
Bases:
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 independent scope which is the union of the outer scope and any identifiers created during the iteration. This scope will also contain a loop variable which has item and index members to access 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. When an item in the iterable is moved the loop.index will be updated to reflect the new index.
The Looper works under the assumption that the values stored in the iterable are unique.
The loop_item and loop_index scope variables are depreciated in favor of loop.item and loop.index respectively. This is because the old loop_index variable may become invalid when items are moved.
- Attributes:
- children
- destroyed
- initialized
- is_destroyed
- is_initialized
- items
- iterable
- name
- parent
- pattern_nodes
Methods
child_added
(child)An overridden child added event handler.
child_moved
(child)A method invoked when a child is moved in the object.
child_node_intercept
(nodes, key, f_locals)Add a child subtree to this pattern.
child_removed
(child)A method invoked when a child is removed from the object.
destroy
()A reimplemented destructor.
find
(name[, regex])Find the first object in the subtree with the given name.
find_all
(name[, regex])Find all objects in the subtree with the given name.
freeze
Freeze the atom to prevent further modifications to its attributes.
get_member
Get the named member for the atom.
has_observer
Get whether the atom has the given observer for a given topic.
has_observers
Get whether the atom has observers for a given topic.
initialize
()A reimplemented initialization method.
insert_children
(before, insert)Insert children into this object at the given location.
members
()Get the members dictionary for the type.
notifications_enabled
Get whether notification is enabled for the atom.
notify
Call the registered observers for a given topic with positional and keyword arguments.
observe
Register an observer callback to observe changes on the given topic(s).
parent_changed
(old, new)A method invoked when the parent of the object changes.
Get a list of items created by the pattern.
Refresh the items of the pattern.
root_object
()Get the root object for this hierarchy.
set_notifications_enabled
Enable or disable notifications for the atom.
set_parent
(parent)Set the parent for this object.
suppress_notifications
()Disable member notifications within in a context.
traverse
([depth_first])Yield all of the objects in the tree, from this object down.
traverse_ancestors
([root])Yield all of the objects in the tree, from this object up.
unobserve
Unregister an observer callback for the given topic(s).
- destroy()[source]¶
A reimplemented destructor.
The looper will release the owned items on destruction.
- 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.
- iterable¶
The iterable to use when creating the items for the looper. The items in the iterable must be unique. This allows the Looper to optimize the creation and destruction of widgets. If the iterable is an Iterator it is first coerced to a tuple.
No implementation found