Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model-based widget creation #379

Closed
wants to merge 16 commits into from
Closed

Conversation

tlambert03
Copy link
Member

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
Copy link

codecov bot commented Feb 22, 2022

Codecov Report

Merging #379 (519e2a7) into main (876190a) will decrease coverage by 2.33%.
The diff coverage is 4.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%) ⬇️
magicgui/_type_wrapper.py 65.70% <0.00%> (-2.53%) ⬇️
magicgui/widgets/_table.py 96.06% <0.00%> (-0.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 876190a...519e2a7. Read the comment docs.

@tlambert03 tlambert03 marked this pull request as draft March 18, 2022 13:02
@tlambert03
Copy link
Member Author

closing this in favor of #446

@tlambert03 tlambert03 closed this Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant