Currently, to make widgets of scrollable, collapsible etc., one must rely on @magicclass decorator with the widget_type argument. This is, however, not efficient if the magic class has only one field.
from magicclass import magicclass, field
from magicclass.widgets import Figure
@magicclass
class A:
@magicclass(widget_type="scrollable")
class Plot:
plt = field(Figure)
ui = A()
ui.Plot.plt.plot(...) # <-- "Plot" is required here :(
This PR implements a type called Box, which adds some functions to a field or a widget class. The word "box" comes from the Box type in Rust, which behaves in a similar way but for different purposes.
from magicclass import magicclass, field
from magicclass.widgets import Figure
from magicclass.box import resizable
@magicclass
class A:
plt = resizable(field(Figure)) # as if `plt = field(Figure)`
ui = A()
ui.plt.plot(...) # <-- OK, and type safe!
Currently, to make widgets of scrollable, collapsible etc., one must rely on
@magicclass
decorator with thewidget_type
argument. This is, however, not efficient if the magic class has only one field.This PR implements a type called
Box
, which adds some functions to a field or a widget class. The word "box" comes from theBox
type in Rust, which behaves in a similar way but for different purposes.TODOs