Package kiwi :: Package ui :: Module objectlist :: Class ObjectList
[frames | no frames]

Type ObjectList

    object --+    
             |    
PropertyObject --+
                 |
    object --+   |
             |   |
      _GObject --+
                 |
                ObjectList

Known Subclasses:
List, ObjectTree

An enhanced version of GtkTreeView, which provides pythonic wrappers for accessing rows, and optional facilities for column sorting (with types) and column selection.

Items in an ObjectList is stored in objects. Each row represents an object and each column represents an attribute in the object. The column description object must be a subclass of Column. Simple example
>>> class Fruit:
>>>    pass
>>> apple = Fruit()
>>> apple.name = 'Apple'
>>> apple.description = 'Worm house'
>>> banana = Fruit()
>>> banana.name = 'Banana'
>>> banana.description = 'Monkey food'
>>> list = ObjectList([Column('name'),
>>>                    Column('description')])
>>> list.append(apple)
>>> list.append(banana)

Method Summary
  add_list(self, instances, clear)
Allows a list to be loaded, by default clearing it first.
  append(self, instance, select)
Adds an instance to the list.
  clear(self)
Removes all the instances of the list
  count(self, item)
L.count(item) -> integer -- return number of occurrences of value
  double_click(self, rowno)
Same as double clicking on the row rowno
  extend(self, iterable)
Extend list by appending elements from the iterable
  get_column_by_name(self, name)
Returns the name of a column
  get_columns(self)
  get_model(self)
Return treemodel of the current list
  get_next(self, instance)
Returns the item after instance in the list.
  get_previous(self, instance)
Returns the item before instance in the list.
  get_selected(self)
Returns the currently selected object If an object is not selected, None is returned
  get_selected_row_number(self)
Return the selected row number or None if no rows were selected
  get_selected_rows(self)
Returns a list of currently selected objects If no objects are selected an empty list is returned
  get_selection_mode(self)
  get_treeview(self)
Return treeview of the current list
  get_treeview_column(self, column)
  index(self, item, start, stop)
Return first index of value
  insert(self, index, item)
L.insert(index, item) -- insert object before index
  pop(self, index)
Remove and return item at index (default last)
  prop_get_selection_mode(self)
  prop_set_selection_mode(self, mode)
  refresh(self, view_only)
Reloads the values from all objects.
  remove(self, instance, select)
Remove an instance from the list.
  reverse(self, pos, item)
L.reverse() -- reverse *IN PLACE*
  select(self, instance, scroll)
  select_paths(self, paths)
Selects a number of rows corresponding to paths
  set_column_visibility(self, column_index, visibility)
  set_columns(self, columns)
  set_headers_visible(self, value)
  set_selection_mode(self, mode)
  sort(self, pos, item)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1
  unselect_all(self)
  update(self, instance)
    Inherited from PropertyObject
  do_get_property(self, pspec)
  do_set_property(self, pspec, value)
  get_attribute_names(self)
  is_default_value(self, attr, value)

Instance Method Details

add_list(self, instances, clear=True)

Allows a list to be loaded, by default clearing it first. freeze() and thaw() are called internally to avoid flashing.
Parameters:
instances - a list to be added
clear - a boolean that specifies whether or not to clear the list

append(self, instance, select=False)

Adds an instance to the list.
  • instance: the instance to be added (according to the columns spec)
  • select: whether or not the new item should appear selected.

clear(self)

Removes all the instances of the list

count(self, item)

L.count(item) -> integer -- return number of occurrences of value

double_click(self, rowno)

Same as double clicking on the row rowno
Parameters:
rowno - integer

extend(self, iterable)

Extend list by appending elements from the iterable
Parameters:
iterable -

get_column_by_name(self, name)

Returns the name of a column

get_model(self)

Return treemodel of the current list

get_next(self, instance)

Returns the item after instance in the list. Note that the instance must be inserted before this can be called If there are no instances after, the first item will be returned.
Parameters:
instance - the instance

get_previous(self, instance)

Returns the item before instance in the list. Note that the instance must be inserted before this can be called If there are no instances before, the last item will be returned.
Parameters:
instance - the instance

get_selected(self)

Returns the currently selected object If an object is not selected, None is returned

get_selected_row_number(self)

Returns:
the selected row number or None if no rows were selected

get_selected_rows(self)

Returns a list of currently selected objects If no objects are selected an empty list is returned

get_treeview(self)

Return treeview of the current list

get_treeview_column(self, column)

Parameters:
column - a @Column

index(self, item, start=None, stop=None)

Return first index of value
Parameters:
item -
start - @param stop

insert(self, index, item)

L.insert(index, item) -- insert object before index

pop(self, index)

Remove and return item at index (default last)
Parameters:
index -

refresh(self, view_only=False)

Reloads the values from all objects.
Parameters:
view_only - if True, only force a refresh of the visible part of this objectlist's Treeview.

remove(self, instance, select=False)

Remove an instance from the list. If the instance is not in the list it returns False. Otherwise it returns True.
Parameters:
instance -
select - if true, the previous item will be selected if there is one.

reverse(self, pos, item)

L.reverse() -- reverse *IN PLACE*

select_paths(self, paths)

Selects a number of rows corresponding to paths
Parameters:
paths - rows to be selected

set_columns(self, columns)

Parameters:
columns - a sequence of Column objects.

set_headers_visible(self, value)

Parameters:
value - if true, shows the headers, if false hide then

sort(self, pos, item)

L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1

Generated by Epydoc 2.1 on Thu Oct 19 03:18:13 2006 http://epydoc.sf.net