swingutils.models.table
¶
-
class
swingutils.models.table.
DelegateTableModel
(delegate, *args)¶ Table model that wraps any list-like object, and fires events when its contents are manipulated (through the table model).
The
__columns__
attribute should be a sequence of (name, class) tuples. The name is used for displaying column headers, and class is used for identifying the type of objects in this column (usually for the purpose of choosing an appropriate cell renderer). You can either override__columns__
in a subclass, or supply it via the constructor.List data is assumed to be a two-dimensional table (list of lists).
-
refresh
()¶ Forces a visual refresh for all rows on related tables. Use this method to visually update tables after you have done changes that did not fire the appropriate table events.
-
-
class
swingutils.models.table.
ObjectTableModel
(delegate, *args)¶ A variant of
DelegateTableModel
where each row in the delegate is assumed to be a single object.Columns are mapped to object attributes. The
__column__
attribute should be a sequence of (name, class, attrname) tuples where attrname is the name of the attribute the column is mapped to.-
getObjectIndex
(obj)¶ Returns the row number that contains the object that is equal to the given object.
Returns: the row number, or -1 if no match was found
-
getSelectedObject
(table)¶ Returns the selected object, or first selected object if the table has multi-row selection enabled.
-
-
class
swingutils.models.table.
TableSelectionMirror
(table)¶ This class provides a “mirror” for the given table’s currently selected object, with support for bound properties regardless of whether the target object itself supports bound properties or not.
This is only useful for use with list-like table models, such as
ObjectTableModel
.