Magic-class

Latest version: v0.7.14

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

Scan your dependencies

Page 6 of 11

0.6.0

New Features
---------------
- Function call will be recorded in macro even if it is called programmatically. Accordingly, macro history is newly introduced to avoid recording too much.
- Even if a sub magic class is defined outside the main magic class and used as a part of it, class will be copied and name space is correctly modified. Now you don't have to literally nest classes. Instead of
python
magicclass
class Main:
magicclass
class A:
...

you can define them separately to keep codes clean.
python
magicclass
class A:
...

magicclass
class Main:
A_widget = A

- `Logger` widget is available in `magicclass.widgets`. This is a very powerful widget for outputs. You can stream `print`, `logging` outputs into the widget using context manager `logger.set_stdout()` and `logger.set_logger()`, or `plt.plot` in this widget just like inline plot using `logger.set_plt()`.
- Fields can be created if `widget_type` is specified.
- Useful types in `magicclass.types`. If `List`, `Tuple` or `Optional` is imported from this submodule, these type annotations will be recognized by `magicgui` and converted into `ListEdit`, `TupleEdit` and `OptionalWidget` respectively. These are temporary ones and may be replaced by `magicgui` in the future.
- `RangeSlider` and `FloatRangeSlider` are available in `magicclass.widgets`. These are temporary ones and may be replaced by `magicgui` in the future.

Bug fixes
----------
- Sub widgets were sometimes completely hidden if closed in `napari`.
- If multiple viewers are created, macro did not work.

Changes
---------
- `__call__` will not be converted to widget because it is meaningless.
- Macro recording of function calls.
- Some types and variables such as `Bound` will be deleted from the main module. They should be imported from submodules from now on. `DeprecationWarning` is raised but will be error in the future.

0.5.22

New Features
---------------
- `xticks` and `yticks` are available in `Figure` widget, just like `plt.xticks` and `plt.yticks`.
- Initial support of `vispy` for mini-viewer. Available in `magicclass.ext.vispy`.

Improvements
----------------
- Inherit style sheet from toolbar to menu hidden in tool buttons.
- Remove underscores in nested menus.
- Warn on widget creation if `set_options` got parameters that do not exists in the wrapping function.
- `"choices"` option did not work in some nested class.
- Remove duplicated `__magicclass_children__`.
- Now `mypy` can correctly resolve typing defined by `Bound`.
- Ensure `ui["x"]` returns a widget (previously returns widget value if `x` is a `MagicValueField`).
- Fix inconsistency in field names.

0.5.21

New Features
---------------
- `OptionalWidget` is available for methods that have optional arguments with `None` as the default .
python
from magicgui import magicgui
from magicclass import Optional

magicgui
def func(x: Optional[int] = None):
print(x)

Currently you have to import `Optional` type from `magicclass` but may also work with `typing.Optional` or `int | None` in the future.
- The `"choices"` option in categorical widgets can be used with instance methods. See document for the detail.
- `enabled` argument in `field` and `vfield`.

Important Changes
---------------------
- The `btn_text` in containers are deprecated now in favor of `text`.
- `Bound(...)` **no longer works** because the `Bound` type is a generic alias now. You should use `Bound[...]` instead.
- Widget alignment of `ScrollableContainer` is changed to `Qt.AlignTop`.
- Delete imports from `magicgui.events`. Now all the warnings of callbacks will raise errors.
- The `type_matching` submodule is **removed**. Similar method may be implemented in `magicgui`.

Bug Fixes
-----------
- Use custom `merge_super_sigs` for correct module updates.
- Some event emissions in `ColorEdit` and `ColorSlider` were broken.
- `MagicField` did not work in Python 3.10 due to wrong `tox` settings.
- Resolve `QColor` warnings.

0.5.20

New Features
---------------
- New widgets `SpreadSheet`, `ColorEdit`, `ColorSlider` are available in `magicclass.widgets`.
- "Show traceback" button in error message box.

Bug Fixes
----------
- Ignore `property` in menu and toolbar.
- Ignore `classmethod`.
- Macro was not locked in callbacks of fields.
- Make `LiteralEvalLineEdit` compatible with magic classes.
- Text was not correctly set in widget actions.

0.5.19

Highlights
------------
- New method `find_ancestor` is available for any magic classes. `ui.find_ancestor(X)` will return an widget of `X` if it is a parent of `ui`. This will be an alternative way to get access to parents, instead of using `wraps`.
- At proper timing, macro recorders for `napari` types (`Viewer` and `Layer` types) will be loaded. They will be recorded like `viewer.layers["name"]` by default.
- Class inheritance is supported in most cases. It safe to define methods, fields or nested classes in the base class and create multiple magic subclasses. See the document for details.

New Features
----------------
- `find_ancestor` method to search for parent widget.
- The `matplotlib`'s widget `Figure` in `magicclass.widgets` now has many methods similar to those used with `plt`. You can use such as `widget.plot(...)` (corresponds to `plt.plot`) and `widget.xlim(...)` (corresponds to `plt.xlim`) instead of `widget.ax.plot()` (correspond to `ax.plot`).
- Load macro recorders for `napari` types.
- `nogui` decorator is available. Methods decorated with this will not be converted to widgets.
- Initial support for stylesheet templates.
- Add weak reference of parent widget to `FunctionGuiPlus` widgets.
- Experimental support of `add_dock_widget` and `remove_dock_widget` methods for `widget_type="mainwindow"`.
- Avoid recording macro if function call ended with an exception.
- New mode `magicclass(error_mode="stdout")`. In this mode error will be printed.

Improvements
----------------
- Don't convert private methods into widgets (previously they were converted but not added).
- Raise clearer error in `FreeWidget` if subclasses are not initialized correctly.
- Support class inheritance.

Bug Fixes
-----------
- `ListDataView` was not recorded in macro correctly.
- `tqdm.ProgressBar` was not updating.
- Safely append functions after widget construction.
- Callbacks of container variations was not called.
- Macro recording of `Enum` was not correct in some cases.

0.5.18

New Features
---------------
- `collapsed` property in collapsible containers. It enables expanding/collapsing widgets programmatically, by such as `ui.collapsed = True`.
- When a magic class has multiple classes decorated with `magictoolbar`, then toolbars will be tabified.
- You can change the initial visibility of a widget by option `magicclass(visible=False)`.
- `FrameContainer` is available, which is similar to `GroupBoxContainer` but does not have title on its top. Available via `magicclass(widget_type="frame")`.
- Make copies of method using `wraps` decorator, using keyword argument `wraps(copy=True)` or without it if multiple `wraps` decorate the same method.
- "Execute selected lines" action in macro widget.
- `magicclass.tqdm` extends `tqdm` usage in `magicgui.tqdm`, which makes `ProgressBar` more useful in magic classes.
- New option `set_options(labels=False)` similar to `magicgui(labels=False)`.
- `confirm` decorator is added (experimentally though). Method decorated with `confirm("xxx")` will open a GUI that confirms whether it's OK to run function.

Bug Fixes and Improvements
--------------------------------
- Adding menu bar and/or toolbar to certain type of containers did not work. Now works with any widgets. This bug fix includes improvement in containers that have scroll area. Menu bar and toolbar will be added outside the scroll area so that they are always visible.
- Many improvements in type annotation of `field` and `vfield`.
- `core.pyi` was not installed.
- Many fixes in type annotation of `magicclass` and other relevant functions.
- GUI took very long time to show up when `napari` is installed because the contents of `napari` happened to be imported in `show()` method.
- Use `object.__setattr__` instead of `setattr` to make widget construction a little bit faster.
- The `current_index` property of tabbed container was broken.
- Remove matplotlib dependency.

Page 6 of 11

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.