Puzzlepiece

Latest version: v0.12.1

Safety actively analyzes 723217 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.12.1

New features:
* You can now omit `self` in param setter/getter and action definitions. Since these are created in the `define_params(self)` method of a Piece, `self` already exists in the namespace. For example:
python
def define_params(self):
pzp.param.readout(self, "digit")
def digit():
return np.random.randint(0, 10)

* Param setter and getters now get unique code object names, meaning that they show up correctly when profiling.
* Thread upgrades: `set_value` and `get_value` are now threadsafe (no promises about user-defined setters and getters though!). Threaded versions of the methods are available, and can be invoked by ctrl+clicking the corresponding GUI buttons (or pressing ctrl+enter) to avoid freezing the GUI. Care should be taken with this though, as setting a value multiple times before the operation finishes can confuse hardware for example.
* Actions can now return values when called.
* The global STOP is now called on exit to help your Pieces wind down gracefully.
* Keyboard shortcuts for actions now work while focus in Popup, and new `Popup.close()` method added.
* New logo! Plus a Q&A section in the documentation.

Fixes:
* The Puzzle and Popups Qt objects are now marked for deletion when closed, avoiding any memory leaks or objects lingering when not expected to.
* ParamSlider no longer emits the `changed` Signal twice when `set_value` is used.
* ParamArray spinner now updates correctly for different getter/setter combinations.
* `self.folder` now set for Pieces _before_ `define_params/define_actions`
* Assorted fixes to get readthedocs to build again

0.12.0

Superseded by v0.12.1, see above.

0.11.0

Added a tutorial! Check it out at https://puzzlepiece.readthedocs.io/en/stable/tutorial.html

New features:
* Puzzles can be indexed in additional ways as a shortcut - you can now directly say `puzzle["piece:param"]` to get a param. This also autocompletes in IPython.
* Child params and actions - use `Popup.make_child_params` to easily create settings popups that modify hidden params.
* `replace_piece` - an experimental method to update a Piece in place.
* `done_signal` for the LiveWorker emitted when it finishes.
* new extra module: `ipython_shims` adds two convenient magics: `%%pzp_script` and `%%safe_run`
* Improvements to `DataGrid`s, including support for custom `Row`s in `add_row` and `Popup`s for the Rows.
* Ability to set a `Popup`'s title.

Fixes:
* `call_stop` stops threads too.
* reduced reliance on Qt spreadsheets - param changes should always indicate correctly with a red background now.

0.10.0

New shortcuts:
* The QApp and Puzzle name arguments are no longer required when creating a Puzzle. The QApp still needs to be created in non-IPython contexts, but it can now be inferred by the Piece.
* You can directly accesss a Piece's params by indexing it like a dictionary:
python
puzzle["piece"]["param_name"]
is now equivalent to
puzzle["piece"].params["param_name"]


New features:
* A slider parameter type - displays a slider and a value label. Min and max values, as well as the step size, are defined on creation.
* First `extra` submodule - `DataGrid`s allow for storing and interacting with data using the `param` abstractions in a table format. Can be added to a Piece's `custom_layout` to enable new data manipulation tasks.

Fixes and enhancements:
* add_piece now returns the Piece instance (useful if a class is being passed for instantiation)
* `v_step` argument when creating spinboxes changes the step of the box's buttons.
* Popups now close when the Puzzle is closed.
* Default param values are cast to the right type on creation.
* IPython exception handler is now inserted correctly even if `puzzle.process_events()` is called in the cell that creates the Puzzle.
* Pieces can now be instantiated without a parent Puzzle. This allows for using the Piece as a standalone Widget in an environment where only one Piece is needed, or a Puzzle cannot be set up, but is in general not advised.
* Option to hide the bottom buttons of a Puzzle (Tree, Export, STOP)
* All code has been re-formatted using ruff.

0.9.0

**Popups** are now available as a convenient way to create a modal window attached to the main Puzzle. Can be used for calibration processes, further settings, or just in general GUI that you don't want cluttering a Piece. See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.piece.html#puzzlepiece.piece.Popup for details.

**Progress bar params** give you a standard way to indicate progress, with tqdm-like iterable wrapping capability:
python
for i in piece.params['progress'].iter(range(10)):
print(i)
this will automatically update the progress bar as the iteration goes on
puzzle.process_events() you may need to refresh the Puzzle to display changes


**Exceptions that arise when running in IPython and interacting with the GUI will now display an error dialog** just like when running in non-interactive Python. Exceptions that arise during cell execution will still produce a traceback in the Notebook, as before.

**Small fixes**: all threads now stop when an exception is raised, and a getter result will be cast to the param's type if obtained during a `set_value` call (that is if the setter doesn't return a value and a getter is present).

See pull request https://github.com/jdranczewski/puzzlepiece/pull/2 for full changes

v0.8.0-bumped
`set_value()` now returns the new value, as it may be different than the one being set if the setter returns a value or a getter is defined.

`ParamArray` has a new property `set_partial` which allows you to set values to slices of the stored numpy array. This calls the setter of the param.
python
puzzle['piece'].params['image'].set_partial[100:200, :] = 128

0.7.0

You can now access the QApplication class as `puzzlepiece.QApp`, and pass Piece classes to `add_piece` instead of instantiating them first - this will reduce the clutter when building applications, and bring the minimum viable app to this neater form:

python
import puzzlepiece as pzp
from puzzlepiece.pieces import random_number

app = pzp.QApp([])
puzzle = pzp.Puzzle(app, "Basic example")
puzzle.add_piece("random", random_number.Piece, 0, 0)
puzzle.show()
app.exec()

Page 1 of 2

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.