puzzlepiece.extras.datagrid module

class puzzlepiece.extras.datagrid.DataGrid(row_class, puzzle=None, parent_piece=None)[source]

Bases: QWidget

A table containing multiple Row objects, each acting kind of like a Piece object, in that it has params and actions (see BaseParam and Action).

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:
  • row_class – The Row class that will be used to construct Rows.

  • puzzle – (optional) The parent Puzzle.

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).

puzzle

Reference to the parent Puzzle.

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

remove_row(id)[source]

Remove the row with the given id.

Parameters:

id – id of the row to remove.

select_row(id)[source]
get_index(row)[source]

Get the current index of a given Row object.

Parameters:

row – the row object.

Return type:

int

clear()[source]

Remove all rows.

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 (see BaseParam and Action).

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

actions

A dictionary of this Row’s actions (see Action).

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:
Return type:

puzzlepiece.piece.Popup