Class k.u.o.ObjectList(PropertyObject, gtk.ScrolledWindow):

Part of kiwi.ui.objectlist

known subclasses: kiwi.ui.objectlist.ObjectTree, kiwi.ui.search.SearchResults, kiwi.ui.widgets.list.List

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'
>>> fruits = ObjectList([Column('name'),
>>>                      Column('description')])
>>> fruits.append(apple)
>>> fruits.append(banana)

Signals

Properties

Function__init__

Create a new ObjectList object.

Function__len__

len(list)

Function__nonzero__

if list

Function__contains__

item in list

Function__iter__

for item in list

Function__getitem__

list[n]

Function__setitem__

list[n] = m

Functionextend

Extend list by appending elements from the iterable

Functionindex

Return first index of value

Functioncount

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

Functioninsert

Inserts an instance to the list

Functionpop

Remove and return item at index (default last)

Functionreverse

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

Functionsort

L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;

Functionsort_by_attribute

Sort by an attribute in the object model.

Functionset_context_menu

Sets a context-menu (eg, when you right click) for the list.

Functionprop_set_selection_modeUndocumented
Functionprop_get_selection_modeUndocumented
Function_loadUndocumented
Function_setup_columnsUndocumented
Function_attach_columnUndocumented
Function_select_and_focus_rowUndocumented
Function_on_model__row_insertedUndocumented
Function_on_model__row_deletedUndocumented
Function_model_sort_func

This method is used to sort the GtkTreeModel

Function_on_selection__changed

This method is used to proxy selection::changed to selection-changed

Function_on_scrolled_window__realizeUndocumented
Function_on_scrolled_window__size_allocate

Resize the Vertical Scrollbar to make it smaller and let space

Function_treeview_search_equal_func

for searching inside the treeview, case-insensitive by default

Function_on_treeview_header__button_release_eventUndocumented
Function_after_treeview__row_activated

After activated (double clicked or pressed enter) on a row

Function_get_selection_or_selected_rowsUndocumented
Function_emit_button_press_signalUndocumented
Function_on_treeview__button_press_event

Generic button-press-event handler to be able to catch double clicks

Function_on_treeview__source_drag_data_getUndocumented
Function_get_column_button

Return the button widget of a particular TreeViewColumn.

Function_setup_popup_button

Put a button on top of the vertical scrollbar to show the popup

Function_find_vertical_scrollbar

This method is called from a .forall() method in the ScrolledWindow.

Function_get_header_heightUndocumented
Functionget_model

Return treemodel of the current list

Functionget_treeview

Return treeview of the current list

Functionget_columnsUndocumented
Functionget_column_by_name

Returns the name of a column

Functionget_treeview_column

Get the treeview column given an objectlist column

Functionset_spinbutton_digits

Set the number of precision digits used by the spinbutton in

Functiongrab_focus

Grabs the focus of the ObjectList

Function_clear_columnsUndocumented
Functionset_columns

Set columns.

Functionappend

Adds an instance to the list.

Function_removeUndocumented
Functionremove

Remove an instance from the list.

FunctionupdateUndocumented
Functionrefresh

Reloads the values from all objects.

Functionset_column_visibilityUndocumented
Functionget_selection_modeUndocumented
Functionset_selection_modeUndocumented
Functionunselect_allUndocumented
Functionselect_paths

Selects a number of rows corresponding to paths

FunctionselectUndocumented
Functionget_selected

Returns the currently selected object

Functionget_selected_rows

Returns a list of currently selected objects

Functionadd_list

Allows a list to be loaded, by default clearing it first.

Functionclear

Removes all the instances of the list

Functionget_next

Returns the item after instance in the list.

Functionget_previous

Returns the item before instance in the list.

Functionget_selected_row_number

Get the selected row number or None if no rows were selected

Functiondouble_click

Same as double clicking on the row rowno

Functionset_headers_visible

Show or hide the headers.

Functionset_visible_rows

Sets the number of visible rows of the treeview. This is useful to use

Functionenable_dnd

Enables Drag and Drop from this object list

Functionget_dnd_targets

Get a list of dnd targets ObjectList supports

def __init__(self, columns=None, objects=None, mode=gtk.SELECTION_BROWSE, sortable=False, model=None):

Create a new ObjectList object.

def __len__(self):

len(list)

def __nonzero__(self):

if list

def __contains__(self, instance):

item in list

def __iter__(self):

for item in list

def __getitem__(self, arg):

list[n]

def __setitem__(self, arg, item):

list[n] = m

def extend(self, iterable):

Extend list by appending elements from the iterable

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

Return first index of value

def count(self, item):

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

def insert(self, index, instance, select=False):

Inserts an instance to the list

def pop(self, index):

Remove and return item at index (default last)

def reverse(self, pos, item):

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

def sort(self, pos, item):

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

def sort_by_attribute(self, attribute, order=gtk.SORT_ASCENDING):

Sort by an attribute in the object model.

def set_context_menu(self, menu):

Sets a context-menu (eg, when you right click) for the list.

def prop_set_selection_mode(self, mode):
Undocumented
def prop_get_selection_mode(self):
Undocumented
def _load(self, instances, clear):
Undocumented
def _setup_columns(self, columns):
Undocumented
def _attach_column(self, column):
Undocumented
def _select_and_focus_row(self, row_iter):
Undocumented
def _on_model__row_inserted(self, model, path, iter):
Undocumented
def _on_model__row_deleted(self, model, path):
Undocumented
def _model_sort_func(self, model, iter1, iter2, (column, attr)):

This method is used to sort the GtkTreeModel

def _on_selection__changed(self, selection):

This method is used to proxy selection::changed to selection-changed

def _on_scrolled_window__realize(self, widget):
Undocumented
def _on_scrolled_window__size_allocate(self, widget, allocation):

Resize the Vertical Scrollbar to make it smaller and let space for the popup button. Also put that button there.

def _treeview_search_equal_func(self, model, tree_column, key, treeiter, column):

for searching inside the treeview, case-insensitive by default

def _on_treeview_header__button_release_event(self, button, event):
Undocumented
def _after_treeview__row_activated(self, treeview, path, view_column):

After activated (double clicked or pressed enter) on a row

def _get_selection_or_selected_rows(self):
Undocumented
def _emit_button_press_signal(self, signal_name, event):
Undocumented
def _on_treeview__button_press_event(self, treeview, event):

Generic button-press-event handler to be able to catch double clicks

def _on_treeview__source_drag_data_get(self, treeview, context, selection, info, timestamp):
Undocumented
def _get_column_button(self, column):

Return the button widget of a particular TreeViewColumn.

This hack is needed since that widget is private of the TreeView but we need access to them for Tooltips, right click menus, ...

Use this function at your own risk

def _setup_popup_button(self):

Put a button on top of the vertical scrollbar to show the popup menu. Internally it uses a POPUP window so you can tell how *Evil* is this.

def _find_vertical_scrollbar(self, widget):

This method is called from a .forall() method in the ScrolledWindow. It just save a reference to the vertical scrollbar for doing evil things later.

def _get_header_height(self):
Undocumented
def get_model(self):

Return treemodel of the current list

def get_treeview(self):

Return treeview of the current list

def get_columns(self):
Undocumented
def get_column_by_name(self, name):

Returns the name of a column

def get_treeview_column(self, column):

Get the treeview column given an objectlist column

def set_spinbutton_digits(self, column_name, digits):

Set the number of precision digits used by the spinbutton in a column.

def grab_focus(self):

Grabs the focus of the ObjectList

def _clear_columns(self):
Undocumented
def set_columns(self, columns):

Set columns.

def append(self, instance, select=False):

Adds an instance to the list.

def _remove(self, objid):
Undocumented
def 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.

def update(self, instance):
Undocumented
def refresh(self, view_only=False):

Reloads the values from all objects.

def set_column_visibility(self, column_index, visibility):
Undocumented
def get_selection_mode(self):
Undocumented
def set_selection_mode(self, mode):
Undocumented
def unselect_all(self):
Undocumented
def select_paths(self, paths):

Selects a number of rows corresponding to paths

def select(self, instance, scroll=True):
Undocumented
def get_selected(self):

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

def get_selected_rows(self):

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

def 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.

def clear(self):

Removes all the instances of the list

def 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.

def 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.

def get_selected_row_number(self):

Get the selected row number or None if no rows were selected

def double_click(self, rowno):

Same as double clicking on the row rowno

def set_headers_visible(self, value):

Show or hide the headers.

def set_visible_rows(self, rows):

Sets the number of visible rows of the treeview. This is useful to use instead of set_size_request() directly, since you can avoid using raw pixel sizes.

def enable_dnd(self):

Enables Drag and Drop from this object list

def get_dnd_targets(self):

Get a list of dnd targets ObjectList supports