List Walker Classes

ListWalker

class urwid.ListWalker
get_focus()

This default implementation relies on a focus attribute and a __getitem__() method defined in a subclass.

Override and don’t call this method if these are not defined.

get_next(position)

This default implementation relies on a next_position() method and a __getitem__() method defined in a subclass.

Override and don’t call this method if these are not defined.

get_prev(position)

This default implementation relies on a prev_position() method and a __getitem__() method defined in a subclass.

Override and don’t call this method if these are not defined.

List-like List Walkers

class urwid.SimpleFocusListWalker(contents)

contents – list to copy into this object

Changes made to this object (when it is treated as a list) are detected automatically and will cause ListBox objects using this list walker to be updated.

Also, items added or removed before the widget in focus with normal list methods will cause the focus to be updated intelligently.

next_position(position)

Return position after start_from.

positions(reverse=False)

Optional method for returning an iterable of positions.

prev_position(position)

Return position before start_from.

set_focus(position)

Set focus position.

set_modified_callback(callback)

This function inherited from MonitoredList is not implemented in SimpleFocusListWalker.

Use connect_signal(list_walker, “modified”, ...) instead.

class urwid.SimpleListWalker(contents)

contents – list to copy into this object

Changes made to this object (when it is treated as a list) are detected automatically and will cause ListBox objects using this list walker to be updated.

contents

Return self.

Provides compatibility with old SimpleListWalker class.

next_position(position)

Return position after start_from.

positions(reverse=False)

Optional method for returning an iterable of positions.

prev_position(position)

Return position before start_from.

set_focus(position)

Set focus position.

set_modified_callback(callback)

This function inherited from MonitoredList is not implemented in SimpleListWalker.

Use connect_signal(list_walker, “modified”, ...) instead.

TreeWalker and Nodes

class urwid.TreeWalker(start_from)

ListWalker-compatible class for displaying TreeWidgets

positions are TreeNodes.

start_from: TreeNode with the initial focus.

class urwid.TreeNode(value, parent=None, key=None, depth=None)

Store tree contents and cache TreeWidget objects. A TreeNode consists of the following elements: * key: accessor token for parent nodes * value: subclass-specific data * parent: a TreeNode which contains a pointer back to this object * widget: The widget used to render the object

get_widget(reload=False)

Return the widget for this node.

load_parent()

Provide TreeNode with a parent for the current node. This function is only required if the tree was instantiated from a child node (virtual function)

class urwid.ParentNode(value, parent=None, key=None, depth=None)

Maintain sort order for TreeNodes.

get_child_keys(reload=False)

Return a possibly ordered list of child keys

get_child_node(key, reload=False)

Return the child node for a given key. Create if necessary.

get_child_widget(key)

Return the widget for a given key. Create if necessary.

get_first_child()

Return the first TreeNode in the directory.

get_last_child()

Return the last TreeNode in the directory.

has_children()

Does this node have any children?

load_child_keys()

Provide ParentNode with an ordered list of child keys (virtual function)

load_child_node(key)

Load the child node for a given key (virtual function)

next_child(key)

Return the next child node in index order from the given key.

prev_child(key)

Return the previous child node in index order from the given key.

set_child_node(key, node)

Set the child node for a given key. Useful for bottom-up, lazy population of a tree..