puzzlepiece.extras.datagrid module
- class puzzlepiece.extras.datagrid.DataGrid(row_class, puzzle=None, parent_piece=None)[source]
Bases:
QWidgetA table containing multiple
Rowobjects, each acting kind of like aPieceobject, in that it has params and actions (seeBaseParamandAction).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(row_class=None, **kwargs)[source]
Add a Row with default param values.
- Parameters:
row_class – row class to use, if not specified uses the one provided when the DataGrid was created. The class provided here should have the same params and actions as the original one!
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
Rowobject.- Parameters:
row – the row object.
- Return type:
int
- add_changed_slot(param_name, function)[source]
Connect a Slot (usually a method) to the
changedSignal 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:
objectA Row is a template for a
DataGridobject, holding the data (params) and actions that the DataGrid displays.It acts kind of like a
Pieceobject, in that it has params and actions (seeBaseParamandAction).- 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.
- open_popup(popup, name=None)[source]
Open a popup window for this Row. See
puzzlepiece.piece.Piece.open_popup().- Parameters:
popup – a
puzzlepiece.piece.Popup_class_ to instantiatename – text to show as the window title
- Return type: