Puzzlepiece

Latest version: v0.11.0

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

Scan your dependencies

Page 1 of 2

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

0.6.1

Small amendment to v0.6.0: ensurers can now capture the exception when called directly, so they can be used in `if` statements easily.

python
This will not raise an Exception is the check fails
if self._ensure_connected(capture_exception=True):
print("laser is connected!")


Original v0.6.0 changelog follows:

---
An ensurer is a decorator that can be placed on getters, setters, and actions, and it will run ahead of these functions. The intended behaviour is performing checks ahead of running the function - for example checking if a laser is connected ahead of trying to set its power. This way one ensurer can be written and used in multiple places easily.

See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.piece.html#puzzlepiece.piece.ensurer for examples

0.6.0

An ensurer is a decorator that can be placed on getters, setters, and actions, and it will run ahead of these functions. The intended behaviour is performing checks ahead of running the function - for example checking if a laser is connected ahead of trying to set its power. This way one ensurer can be written and used in multiple places easily.

See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.piece.html#puzzlepiece.piece.ensurer for examples

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.