Package tkintertable :: Module TableModels :: Class TableModel
[hide private]
[frames] | no frames]

Class TableModel

source code

object --+
         |
        TableModel

A base model for managing the data in a TableCanvas class

Instance Methods [hide private]
 
__init__(self, newdict=None, rows=None, columns=None)
Constructor
source code
 
setupModel(self, newdict, rows=None, columns=None)
Create table model
source code
 
initialiseFields(self)
Create base fields, some of which are not saved
source code
 
createEmptyModel(self)
Create the basic empty model dict
source code
 
importDict(self, newdata)
Try to create a table model from a dict of the form...
source code
 
getDefaultTypes(self)
Get possible field types for this table model
source code
 
getData(self)
Return the current data for saving
source code
 
getAllCells(self)
Return a dict of the form rowname: list of cell contents Useful for a simple table export for example
source code
 
getColCells(self, colIndex)
Get the viewable contents of a col into a list
source code
 
getlongestEntry(self, columnIndex)
Get the longest cell entry in the col
source code
 
getRecordAtRow(self, rowIndex)
Get the entire record at the specifed row.
source code
 
getCellRecord(self, rowIndex, columnIndex)
Get the data held in this row and column
source code
 
deleteCellRecord(self, rowIndex, columnIndex)
Remove the cell data at this row/column
source code
 
getRecName(self, rowIndex)
Get record name from row number
source code
 
setRecName(self, newname, rowIndex)
Set the record name to another value - requires re-setting in all dicts that this rec is referenced
source code
 
getRecordAttributeAtColumn(self, rowIndex=None, columnIndex=None, recName=None, columnName=None)
Get the attribute of the record at the specified column index.
source code
 
getRecordIndex(self, recname) source code
 
setSortOrder(self, columnIndex=None, columnName=None, reverse=0)
Changes the order that records are sorted in, which will be reflected in the table upon redrawing
source code
 
createSortMap(self, names, sortkey, reverse=0)
Create a sort mapping for given list
source code
 
toFloats(self, l) source code
 
moveColumn(self, oldcolumnIndex, newcolumnIndex)
Changes the order of columns
source code
 
getNextKey(self)
Return the next numeric key in the dict
source code
 
addRow(self, key=None, **kwargs)
Add a row
source code
 
deleteRow(self, rowIndex=None, key=None, update=True)
Delete a row
source code
 
deleteRows(self, rowlist=None)
Delete multiple or all rows
source code
 
addColumn(self, colname=None, coltype=None)
Add a column
source code
 
deleteColumn(self, columnIndex)
delete a column
source code
 
deleteColumns(self, cols=None)
Remove all cols or list provided
source code
 
autoAddRows(self, numrows=None)
Automatically add x number of records
source code
 
autoAddColumns(self, numcols=None)
Automatically add x number of cols
source code
 
relabel_Column(self, columnIndex, newname)
Change the column label - can be used in a table header
source code
 
getColumnType(self, columnIndex)
Get the column type
source code
 
getColumnCount(self)
Returns the number of columns in the data model.
source code
 
getColumnName(self, columnIndex)
Returns the name of the given column by columnIndex.
source code
 
getColumnLabel(self, columnIndex)
Returns the label for this column
source code
 
getColumnIndex(self, columnName)
Returns the column index for this column
source code
 
getColumnData(self, columnIndex=None, columnName=None, filters=None)
Return the data in a list for this col, filters is a tuple of the form (key,value,operator,bool)
source code
 
getColumns(self, colnames, filters=None, allowempty=True)
Get column data for multiple cols, with given filter options, filterby: list of tuples of the form (key,value,operator,bool) allowempty: boolean if false means rows with empty vals for any required fields are not returned returns: lists of column data
source code
 
getDict(self, colnames, filters=None)
Get the model data as a dict for given columns with filter options
source code
 
filterBy(self, filtercol, value, op='contains', userecnames=False, progresscallback=None)
The searching function that we apply to the model data.
source code
 
getRowCount(self)
Returns the number of rows in the table model.
source code
 
getValueAt(self, rowIndex, columnIndex)
Returns the cell value at location specified by columnIndex and rowIndex.
source code
 
setValueAt(self, value, rowIndex, columnIndex)
Changed the dictionary when cell is updated by user
source code
 
setFormulaAt(self, f, rowIndex, columnIndex)
Set a formula at cell given
source code
 
getColorAt(self, rowIndex, columnIndex, key='bg')
Return color of that record field for the table
source code
 
setColorAt(self, rowIndex, columnIndex, color, key='bg')
Set color
source code
 
resetcolors(self)
Remove all color formatting
source code
 
getRecColNames(self, rowIndex, ColIndex)
Returns the rec and col name as a tuple
source code
 
getRecAtRow(self, recname, colname, offset=1, dim='y')
Get the record name at a specified offset in the current table from the record given, by using the current sort order
source code
 
appendtoFormula(self, formula, rowIndex, colIndex)
Add the input cell to the formula
source code
 
doFormula(self, cellformula)
Evaluate the formula for a cell and return the result
source code
 
copyFormula(self, cellval, row, col, offset=1, dim='y')
Copy a formula down or across, using the provided offset
source code
 
merge(self, model, key='name', fields=None)
Merge another table model with this one based on a key field, we only add records from the new model where the key is present in both models
source code
 
save(self, filename=None)
Save model to file
source code
 
load(self, filename)
Load model from pickle file
source code
 
copy(self)
Return a copy of this model
source code
 
__repr__(self)
repr(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  keywords = {'colors': 'colors', 'columnlabels': 'columnlabels'...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, newdict=None, rows=None, columns=None)
(Constructor)

source code 

Constructor

Overrides: object.__init__

importDict(self, newdata)

source code 
Try to create a table model from a dict of the form
{{'rec1': {'col1': 3, 'col2': 2}, ..}

getRecordAttributeAtColumn(self, rowIndex=None, columnIndex=None, recName=None, columnName=None)

source code 

Get the attribute of the record at the specified column index. This determines what will be displayed in the cell

filterBy(self, filtercol, value, op='contains', userecnames=False, progresscallback=None)

source code 

The searching function that we apply to the model data. This is used in Filtering.doFiltering to find the required recs according to column, value and an operator

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

Class Variable Details [hide private]

keywords

Value:
{'colors': 'colors',
 'columnlabels': 'columnlabels',
 'columnnames': 'columnNames',
 'columnorder': 'columnOrder',
 'columntypes': 'columntypes'}