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

Create widget from factory #18

Merged
merged 10 commits into from
Dec 14, 2021
Merged

Create widget from factory #18

merged 10 commits into from
Dec 14, 2021

Conversation

trungleduc
Copy link
Owner

@trungleduc trungleduc commented Dec 12, 2021

In the case of using existing widgets in FlexLayout dashboard, users can create multiple views of a widget, so all tabs are linked.

If users want to have the independent widget in each tab, FlexLayout allows users to define the factories to create widgets from the interface.

def slider_factory(label: 'Label of slider', value: 'Initial value'):
    return ipywidgets.FloatSlider(value=float(value), description=label )

factories = {"Slider factory": slider_factory}

dashboard = FlexLayout(factories=factories)

factory_widget

  • If the factory function needs parameters, FlexLayout will build an input form to get parameters from the interface. Users can define annotations to have the label of the input form.

  • FlexLayout will pass all parameters as string, users need to convert the inputs to their appropriate type in the factory function.

Close #17

@trungleduc trungleduc marked this pull request as ready for review December 13, 2021 22:32
@trungleduc
Copy link
Owner Author

cc @mtbli

@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on this branch

1 similar comment
@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on this branch

@trungleduc trungleduc merged commit 4ef8f0f into master Dec 14, 2021
@trungleduc trungleduc added this to the 0.2.0 milestone Dec 16, 2021
@trungleduc trungleduc added enhancement New feature or request UI labels Dec 16, 2021
@trungleduc trungleduc deleted the ft/widget-factory branch December 26, 2021 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the possibility of creating multiple instances of the same widget
1 participant