magicgui
magicgui copied to clipboard
Model-based widget creation
quite similar to #318 ... this pattern would use pydantic directly in widget declaration:
from magicgui import Field, GUIModel
from magicgui.widgets import Slider
# this is a pydantic subclass
class MyWidget(GUIModel):
x: int = 1
# magicgui kwargs are prefaced by ui_
y: int = Field(2, ui_widget_type=Slider)
class Config:
#container kwargs in the config
layout = "horizontal"
obj = MyWidget()
obj.x # values are directly on the object, like pydantic
obj.events.x.connect # events are in a psygnal group
obj.gui.show(run=True) # the widget is at the `.gui` attribute
Codecov Report
Merging #379 (519e2a7) into main (876190a) will decrease coverage by
2.33%. The diff coverage is4.08%.
@@ Coverage Diff @@
## main #379 +/- ##
==========================================
- Coverage 88.64% 86.30% -2.34%
==========================================
Files 30 31 +1
Lines 3804 3900 +96
==========================================
- Hits 3372 3366 -6
- Misses 432 534 +102
| Impacted Files | Coverage Δ | |
|---|---|---|
| magicgui/_gui_model.py | 0.00% <0.00%> (ø) |
|
| magicgui/types.py | 97.67% <80.00%> (-2.33%) |
:arrow_down: |
| magicgui/_type_wrapper.py | 65.70% <0.00%> (-2.53%) |
:arrow_down: |
| magicgui/widgets/_table.py | 96.06% <0.00%> (-0.25%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 876190a...519e2a7. Read the comment docs.
closing this in favor of #446