The swingutils.models package offers a collection of useful models for most Swing components that require the use of models.
This class wraps a Python list object and implements the javax.swing.table.TableModel` interface. All elements of the wrapped list are expected to be lists or tuples (or any other indexed collections). Column names and types are provided in the constructor as a series of 2-tuples:
from java.lang import String, Integer from swingutils.models.table import DelegateTableModel model = DelegateTableModel(somedata, ('Name', String), ('Age', Integer), 'Hometown')
As you probably noticed, the last column was not a tuple, but a string. This translates to ('HomeTown', Object). The reason why types are given as Java types is to give the default column renderer a hint for choosing the correct renderer for this column.
This table model is much more useful than its parent class (DelegateTableModel). The contents of the wrapped list object are expected to be objects, and columns are mapped to their attributes. Therefore the constructor expects an series of 3-tuples (name, type, attribute name). You can no longer use the name-only shortcut of only providing the name as a string – you have to give all three values.