Module eagle :: Class Table
[show private | hide private]
[frames | no frames]

Type Table

object --+        
         |        
 _EGObject --+    
             |    
     _EGWidget --+
                 |
                Table


Data table.

Each column should have only one type, it will be checked. Can be accessed as a python list:
>>> t = Table( 't', 'table', [ 1, 2, 3 ] )
>>> t[ 0 ]
[ 1 ]

>>> del t[ 1 ]
>>> t[ : ]
[ 1, 3 ]

Method Summary
  __init__(self, id, label, items, types, selected, headers, show_headers, editable, repositioning, expand_columns_indexes, hidden_columns_indexes, cell_format_func, user_widgets, selection_callback, data_changed_callback, scrollbars, expand_policy, active, visible)
Table constructor.
  __contains__(self, row)
  __create_column_cell_format_func__(self, col, cell_rend)
  __delitem__(self, index)
  __delslice__(self, start, end)
  __get_default_value_function_for_type__(self, type)
  __getitem__(self, index)
  __getslice__(self, start, end)
  __iadd__(self, other)
  __len__(self)
  __nonzero__(self)
  __setitem__(self, index, other)
  __setslice__(self, start, end, slice)
  __setup_connections__(self)
  __setup_connections_changed__(self)
  __setup_connections_selection__(self)
  __setup_gui__(self)
  __setup_items__(self)
  __setup_model__(self)
  __setup_table__(self)
  add_callback(self)
Callback for 'Add' button.
  add_dialog(self, data)
Dialog used to edit data from table.
  append(self, row, select, autosize)
  clear(self)
  columns_autosize(self)
  del_callback(self, rows)
Callback for 'Delete' button.
  edit_callback(self, rows)
Callback for 'Edit' button.
  edit_dialog(self, data)
Dialog used to edit data from table.
  extend(self, rows, select, autosize)
  focus(self)
Give keyboard focus to this widget.
  get_label(self)
  insert(self, index, row, select, autosize)
  move_down_callback(self, index)
  move_up_callback(self, index)
  select(self, index)
  selected(self)
  set_label(self, label)
  _get_app(self)
  _set_app(self, value)
    Inherited from _EGWidget
  __configure_orientation__(self, setting)
  __get_widgets__(self)
Return a list of internal widgets this Eagle widget contains.
  _get_widgets(self)
  _set_widgets(self, value)
  disable(self)
Same as set_active( False )
  enable(self, active)
Set the widget as active.
  get_active(self)
Return True if it's active (enabled) or False inactive (disabled).
  get_visible(self)
Return true if widget is visible (shown).
  hide(self)
Make widget invisible.
  is_active(self)
Return True if it's active (enabled) or False inactive (disabled).
  is_enabled(self)
Return True if it's active (enabled) or False inactive (disabled).
  is_visible(self)
Return true if widget is visible (shown).
  set_active(self, active)
Set the widget as active.
  set_inactive(self)
Same as set_active( False )
  set_visible(self, visible)
Show or hide widget based on value of 'visible'.
  show(self)
Make widget visible.
    Inherited from _EGObject
  __repr__(self)
  __str__(self)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
  app
  label
    Inherited from _EGWidget
  _widgets
  active
  visible
    Inherited from _EGObject
  id

Class Variable Summary
dict default_value_function_for_type = {<type 'bool'>: <type ...
int spacing = 3                                                                     
type CellFormat = eagle.CellFormat
type Row = eagle.Row
    Inherited from _EGWidget
int ORIENTATION_HORIZONTAL = 1                                                                     
int ORIENTATION_VERTICAL = 0                                                                     

Method Details

__init__(self, id, label='', items=None, types=None, selected=None, headers=None, show_headers=True, editable=False, repositioning=False, expand_columns_indexes=None, hidden_columns_indexes=None, cell_format_func=None, user_widgets=None, selection_callback=None, data_changed_callback=None, scrollbars=True, expand_policy=None, active=True, visible=True)
(Constructor)

Table constructor.

Table can work with not known objects, they just need to
implement some methods:
 - type.default_value(): return a new, possible non
   initialized instance. Used in default L{add_callback()}
 - object.commit(): changes were made and they should be
   commited.
 - object.rollback(): changes were made and they should be
   reverted.
 - object.delete(): delete object
 - object.get_edit_widget(): get eagle widget to use to edit
   this object.

@param id: unique identifier.
@param label: what to show on table frame
@param items: a list (single column) or list of lists (multiple
       columns)
@param types: a list of types (str, int, long, float, unicode, bool)
       for columns, if omitted, will be guessed from items.
@param selected: index of selected row or None, for no pre-selected.
@param headers: what to use as table header.
@param show_headers: whenever to show table headers
@param editable: if table is editable. If editable, user can change
       values inline or double-clicking, also edit buttons will
       show after the table.
@param repositioning: allow items to be moved up and down.
@param expand_columns_indexes: list of indexes that can expand size
@param cell_format_func: if define, should return a CellFormat with
       properties to be applied to cell. Only non-None properties will
       be used. Function should have the following signature:
          def func( app, table, row, col, value ):
              return Table.CellFormat( ... )
       where row and col are indexes in table.
@param user_widgets: widgets to be appended to table's
       actions, just after edit or move buttons.
@param selection_callback: the function (or list of functions) to
       call when selection changes. Function will get as parameters:
        - App reference
        - Table reference
        - List of pairs ( index, row_contents )
@param data_changed_callback: the function (or list of functions) to
       call when data changes. Function will get as parameters:
        - App reference
        - Table reference
        - Pair ( index, row_contents )
@param scrollbars: whenever to use scrollbars and make table
       fit small places.
@param expand_policy: how this widget should fit space, see
       L{ExpandPolicy.Policy.Rule}.

@warning: although this widget contains data, it's not a
          _EGDataWidget and thus will not notify application that
          data changed, also it cannot persist it's data
          automatically, if you wish, do it manually. This behavior
          may change in future if Table show to be useful as
          _EGDataWidget.
Overrides:
eagle._EGWidget.__init__

add_callback(self)

Callback for 'Add' button.

This method is called when 'Add' button, visible when editable=True, is clicked.

Default implementation creates a new row using some defaults for known objects, like bool, numbers and strings or calls default_value() on type to get some default value. If none of these are available, then None will be used.

If user accept values, row will be append()ed to table, otherwise it will be forgotten and garbage collector will remove then.

If type is not known by system (so default_value() was called), object.commit() will be called, otherwise object.rollback() will be called. You can use this to perform some action on database.

It can be overloaded by applications so more ellaborated actions can be done.

add_dialog(self, data)

Dialog used to edit data from table.
Parameters:
data - some row from table. @return None if user cancelled action or new row to replace the old one.

del_callback(self, rows)

Callback for 'Delete' button.

This method is called when 'Delete' button, visible when editable=True, is clicked.

If row object has delete(), it will be called before row is excluded.

edit_callback(self, rows)

Callback for 'Edit' button.

This method is called when 'Edit' button, visible when editable=True, is clicked.

If row objects has commit() or rollback() methods, they'll be called based on user action (entry_dialog() returned row or None)
Parameters:
rows - a list of tuples with (index, row), just like selected()

edit_dialog(self, data)

Dialog used to edit data from table.
Parameters:
data - some row from table. @return None if user cancelled action or new row to replace the old one.

focus(self)

Give keyboard focus to this widget.
Overrides:
eagle._EGWidget.focus (inherited documentation)

Property Details

app

Get Method:
_get_app(self)
Set Method:
_set_app(self, value)

label

Get Method:
get_label(self)
Set Method:
set_label(self, label)

Class Variable Details

default_value_function_for_type

Type:
dict
Value:
{<type 'bool'>: <type 'bool'>,
 <type 'float'>: <type 'float'>,
 <type 'int'>: <type 'int'>,
 <type 'long'>: <type 'long'>,
 <type 'str'>: <type 'str'>,
 <type 'unicode'>: <type 'unicode'>}                                   

spacing

Type:
int
Value:
3                                                                     

Generated by Epydoc 2.1 on Sun Apr 22 21:30:28 2007 http://epydoc.sf.net