Releases: hanjinliu/magic-class
Releases · hanjinliu/magic-class
v0.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
you can define them separately to keep codes clean.
@magicclass class Main: @magicclass class A: ...
@magicclass class A: ... @magicclass class Main: A_widget = A
Logger
widget is available inmagicclass.widgets
. This is a very powerful widget for outputs. You can streamprint
,logging
outputs into the widget using context managerlogger.set_stdout()
andlogger.set_logger()
, orplt.plot
in this widget just like inline plot usinglogger.set_plt()
.- Fields can be created if
widget_type
is specified. - Useful types in
magicclass.types
. IfList
,Tuple
orOptional
is imported from this submodule, these type annotations will be recognized by@magicgui
and converted intoListEdit
,TupleEdit
andOptionalWidget
respectively. These are temporary ones and may be replaced bymagicgui
in the future. RangeSlider
andFloatRangeSlider
are available inmagicclass.widgets
. These are temporary ones and may be replaced bymagicgui
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.
v0.5.22
New Features
xticks
andyticks
are available inFigure
widget, just likeplt.xticks
andplt.yticks
.- Initial support of
vispy
for mini-viewer. Available inmagicclass.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 byBound
. - Ensure
ui["x"]
returns a widget (previously returns widget value ifx
is aMagicValueField
). - Fix inconsistency in field names.
v0.5.21
New Features
OptionalWidget
is available for methods that have optional arguments withNone
as the default .Currently you have to importfrom magicgui import magicgui from magicclass import Optional @magicgui def func(x: Optional[int] = None): print(x)
Optional
type frommagicclass
but may also work withtyping.Optional
orint | None
in the future.- The
"choices"
option in categorical widgets can be used with instance methods. See document for the detail. enabled
argument infield
andvfield
.
Important Changes
- The
btn_text
in containers are deprecated now in favor oftext
. Bound(...)
no longer works because theBound
type is a generic alias now. You should useBound[...]
instead.- Widget alignment of
ScrollableContainer
is changed toQt.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 inmagicgui
.
Bug Fixes
- Use custom
merge_super_sigs
for correct module updates. - Some event emissions in
ColorEdit
andColorSlider
were broken. MagicField
did not work in Python 3.10 due to wrongtox
settings.- Resolve
QColor
warnings.
v0.5.20
New Features
- New widgets
SpreadSheet
,ColorEdit
,ColorSlider
are available inmagicclass.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.
v0.5.19
Highlights
- New method
find_ancestor
is available for any magic classes.ui.find_ancestor(X)
will return an widget ofX
if it is a parent ofui
. This will be an alternative way to get access to parents, instead of using@wraps
. - At proper timing, macro recorders for
napari
types (Viewer
andLayer
types) will be loaded. They will be recorded likeviewer.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 widgetFigure
inmagicclass.widgets
now has many methods similar to those used withplt
. You can use such aswidget.plot(...)
(corresponds toplt.plot
) andwidget.xlim(...)
(corresponds toplt.xlim
) instead ofwidget.ax.plot()
(correspond toax.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
andremove_dock_widget
methods forwidget_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.
v0.5.18
New Features
collapsed
property in collapsible containers. It enables expanding/collapsing widgets programmatically, by such asui.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 toGroupBoxContainer
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
extendstqdm
usage inmagicgui.tqdm
, which makesProgressBar
more useful in magic classes.- New option
set_options(labels=False)
similar tomagicgui(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
andvfield
. 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 ofnapari
happened to be imported inshow()
method. - Use
object.__setattr__
instead ofsetattr
to make widget construction a little bit faster. - The
current_index
property of tabbed container was broken. - Remove matplotlib dependency.
v0.5.17
This release fixed an important bug in v0.5.16
.
Bug Fixes
NameError
when optional packages are not installed.labels=False
option in menu bar and toolbar took no effect.
Changes
- All the extended widgets such as
QtConsole
andQtPlotCanvas
are moved tomagicclss.ext
submodule. They are no longer available inmagicclass.widgets
.
Improvements
- Better typing in
MagicField
. For instance, if you have a fieldf = field(SpinBox)
then type checker knows thatf
will be aSpinBox
when accessed via GUI instance. - Containers with scroll area (
magicclass
optionswidget_type="scrollable"
orwidget_type="draggable"
) will assign menu bar and tool bar outside their scroll area so that menu bar and tool bar are always visible.
v0.5.16
New Features
- New methods
add_text
,add_infline
inpyqtgraph
based widgets. - Initial support for
pyvista
(WIP). Available inmagicclass.widgets
- Both menu and toolbar can be defined in non-main window.
set_options
can takeauto_call
,call_button
,layout
arguments.
Bug Fixes
MagicField
callback bug fix.- Toolbar updates its style sheet when added to
napari
viewer. - Update
FunctionGui
categorical widgets hidden in buttons and actions.
v0.5.15
New Features
- Many updates in
pyqtgraph
based widgets.QtPlotCanvas
supports histogram and bar plot. It also has a linear region item incanvas.region
by default.QtImageCanvas
has scale bar by default. The LUT histogram is hidden by the button on the upper-left corner now.- Much more unified API between line plot item, scatter plot item and others, such as
face_color
,edge_color
andsymbol
. QtMultiPlotCanvas
,QtMultiImageCanvas
can contain multiple plots and images in a single widget.Qt2YPlotCanvas
has two Y-axis and shared X-axis.
to_napari
function is available inmagicclass.ext
submodule. Any magic classes, no matter it is a widget or a menu, can directly docked intonapari
viewer by simple syntax:from magicclass.ext import to_napari @to_napari @magicclass class A: ...
- Now functions can be converted into buttons or menus after construction of magic classes. This also follows the
magicgui
's typing rule.def func(a: int): ... ui.Menu.append(func) # this code will create a new action in Menu.
Changes
parent_viewer
finds viewer ancestor in a safer way now. It usesnapari
's method so that it will also work with newernapari
in the future.- Use pyi file to improve code completion.
v0.5.14
New Features
magictoolbar
creates aToolBarGui
, which appears as a tool bar on the top of a widget. It is inter-nestable withmagicmenu
.- Horizontal collapsible container using
widget_type="hcollapsible"
. - Automatically determine how to execute
QApplication
. In the previous versions you had to add such asinput()
to prevent application exiting immediately if you ran a ".py" file withpython
command. Now you don't have to do that. - Icon supports in many widgets.
icon_path
is now a universal option for widgets and fields. It can be used as@magicclass(icon_path="...")
,field(int, options={"icon_path": "..."})
.ConsoleTextEdit
has new propertytab_size
, with which you can set the size of tab.
Bug Fixes
- Checkable actions in menus were not working.
wraps
was not working when a magic class was defined locally.
Others
- Added many tests.
- Remove
matplotlib
dependency.