puzzlepiece.extras.datagrid module
- class puzzlepiece.extras.datagrid.DataGrid(row_class, puzzle=None)[source]
Bases:
QWidget
A table containing multiple
Row
objects, each acting kind of like aPiece
object, in that it has params and actions (seeBaseParam
andAction
).This is a QWidget, co it can be added to your Piece’s
custom_layout()
or used as a standalone Widget if you know what you’re doing.This is not very performant, very large numbers of Rows should be avoided! Consider using Qt’s QTableWidget instead.
- Parameters:
- rows_changed
A Qt signal emitted when a row is added or removed.
- data_changed
A Qt signal emitted when any data in the DataGrid changes (including when rows are added/removed).
- rows
A list of Rows.
- property values
The current values for all params in the Rows (this does not invoke their getters).
- add_row(**kwargs)[source]
Add a Row with default param values.
- Parameters:
kwargs – keyword arguments matching param names can be passed to set param values in the new row
- get_index(row)[source]
Get the current index of a given
Row
object.- Parameters:
row – the row object.
- Return type:
int
- add_changed_slot(param_name, function)[source]
Connect a Slot (usually a method) to the
changed
Signal of the given param in all the rows (including Rows added in the future).- Parameters:
param_name – The name of the param whose changed Signal we’re connecting to.
function – any method or other Qt Slot to connect.
- class puzzlepiece.extras.datagrid.Row(parent=None, puzzle=None)[source]
Bases:
object
A Row is a template for a
DataGrid
object, holding the data (params) and actions that the DataGrid displays.It acts kind of like a
Piece
object, in that it has params and actions (seeBaseParam
andAction
).- Parameters:
parent – (optional) The parent DataGrid.
- Parem puzzle:
(optional) The parent Puzzle.
- params
A dictionary of this Row’s params (see
BaseParam
). You can also directly index the Row object with the param name.- Type:
dict
- define_params()[source]
Override to define params using decorators from
puzzlepiece.param
.
- define_actions()[source]
Override to define actions using decorators from
puzzlepiece.action
.