Package ocempgui :: Package widgets :: Package components :: Module ListItemCollection :: Class ListItemCollection
[show private | hide private]
[frames | no frames]

Class ListItemCollection

UserList --+
           |
          ListItemCollection


ListItemCollection (items=None) -> ListItemCollection

An collection class for ListItem objects.

The ListItemCollection wraps a list object and limits it to the
abstract ListItem class type, so that it is guaranteed, that the
collection only contains a specific object type.

It adds a notification slot 'list_changed', to which a method or
function can be connected either by assigning the attribute directly
or using the set_list_changed() method. The slot'ed callback will be
invoked, whenever the list contents change. The signature of the
function or method to connect has to get one argument, which will be
the ListItemCollection.

class Example:
    ...

    def list_callback (self, collection):
        ...

collection.list_changed = object_example.list_callback
collection.set_list_changed (object_example.list_callback)

The ListItemCollection also adds a notification slot 'item_changed',
to which a method or function can be connected using (again) the
attribute directly or the set_item_changed() method. The callback
will be invoked, whenever a ListItem of the collection changes and
calls the callback. The signature of the function or method to
connect has to get one argument, which will be the ListItem, which
invoked it.

class Example:
    ...

    def item_callback (self, item):
        ...

collection.item_changed = object_example.item_callback
collection.set_item_changed (object_example.item_callback)

The ListItemCollection does support the usual list operations such as
appending, insertion and removal using indices, slicing,the count()
and len() methods and the list iterator.

Attributes:
length       - Amount of the items attached to the ListItemCollection.
list_changed - Slot to connect a method to, which will be called whenever
               the contents of the ListItemCollection change.
item_changed - Slot to connect a method to, which will be called whenever
               an item of the ListItemCollection changes.

Method Summary
  __init__(self, items)
  __len__(self)
L.__len__ () -> len (L)
  __setitem__(self, index, item)
L.__setitem__ (index, item) -> L[index] = item
  __setslice__(self, i, j, collection)
L.__setslice__ (i, j, collection) -> L[i:j] = collection
  append(self, item)
L.append (...) -> None
  count(self, item)
L.count (...) -> int
  insert(self, index, item)
L.insert (...) -> None
  remove(self, item)
L.remove (...) -> None
  set_item_changed(self, method)
L.set_item_changed (...) -> None
  set_list_changed(self, method)
L.set_list_changed (...) -> None
  sort(self, cmp, key, reverse)
L.sort (...) -> None
    Inherited from UserList
  __add__(self, other)
  __cmp__(self, other)
  __contains__(self, item)
  __delitem__(self, i)
  __delslice__(self, i, j)
  __eq__(self, other)
  __ge__(self, other)
  __getitem__(self, i)
  __getslice__(self, i, j)
  __gt__(self, other)
  __iadd__(self, other)
  __imul__(self, n)
  __le__(self, other)
  __lt__(self, other)
  __mul__(self, n)
  __ne__(self, other)
  __radd__(self, other)
  __repr__(self)
  __rmul__(self, n)
  extend(self, other)
  index(self, item, *args)
  pop(self, i)
  reverse(self)

Property Summary
  item_changed: Notifier slot for item changes.
  length: Amount of the attached items.
  list_changed: Notifier slot for collection changes.

Method Details

__len__(self)
(Length operator)

L.__len__ () -> len (L)
Overrides:
UserList.UserList.__len__

__setitem__(self, index, item)
(Index assignment operator)

L.__setitem__ (index, item) -> L[index] = item

Raises a TypeError, if the passed item argument does not inherit from the ListItem class.
Overrides:
UserList.UserList.__setitem__

__setslice__(self, i, j, collection)
(Slice assignment operator)

L.__setslice__ (i, j, collection) -> L[i:j] = collection

Raises a TypeError, if the passed collection argument does not inherit from the ListItemCollection class.
Overrides:
UserList.UserList.__setslice__

append(self, item)

L.append (...) -> None

Appends a ListItem to the end of the ListItemCollection

Raises a TypeError, if the passed argument does not inherit from the ListItem class.
Overrides:
UserList.UserList.append

count(self, item)

L.count (...) -> int

Returns the number of occurences of the ListItem.

Raises a TypeError, if the passed argument does not inherit from the ListItem class.
Overrides:
UserList.UserList.count

insert(self, index, item)

L.insert (...) -> None

Inserts the ListItem before index.

Raises a TypeError, if the passed item argument does not inherit from the ListItem class.
Overrides:
UserList.UserList.insert

remove(self, item)

L.remove (...) -> None

Removes the first occurance of item from the ListItemCollection.
Overrides:
UserList.UserList.remove

set_item_changed(self, method)

L.set_item_changed (...) -> None

Connects a method to invoke, when an item of the collection changes.

Raises a TypeError, if the passed argument is not callable.

set_list_changed(self, method)

L.set_list_changed (...) -> None

Connects a method to invoke, when the collection changes.

Raises a TypeError, if the passed argument is not callable.

sort(self, cmp=None, key=None, reverse=False)

L.sort (...) -> None

Stable in place sort for the ListItemCollection.
Overrides:
UserList.UserList.sort

Property Details

item_changed

Notifier slot for item changes.
Get Method:
unknown-696519284(...)
Set Method:
unknown-696519340(...)

length

Amount of the attached items.
Get Method:
unknown-696519116(...)

list_changed

Notifier slot for collection changes.
Get Method:
unknown-696519172(...)
Set Method:
unknown-696519228(...)

Generated by Epydoc 2.1 on Thu Jan 10 10:18:43 2008 http://epydoc.sf.net