Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from trungleduc/ft/widget-factory
Create widget from factory
- Loading branch information
Showing
15 changed files
with
567 additions
and
537 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"path": "../../../examples/widget_factory/widget_factory.ipynb", | ||
"extra-media": ["../../../examples/widget_factory/"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d4c569c9-9060-4245-abdf-3a434f2c3a67", | ||
"metadata": {}, | ||
"source": [ | ||
"## A widget factory example" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "8e9ceab0-5b1d-413b-8744-bb3ea92dc6cb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import ipywidgets\n", | ||
"from ipyflex import FlexLayout" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "887ba9a0-a506-49ae-8324-aeb36535b791", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"slider = ipywidgets.FloatSlider(description='Linked slider')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "94b10897-0011-4c76-b14f-663710581d05", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def slider_factory(label: 'Label of slider', value: 'Initial value'):\n", | ||
" return ipywidgets.FloatSlider(value=float(value), description=label )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "6b13a1d1-183f-478a-8ddc-f4ee44208efc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"widgets = {'Linked slider': slider}\n", | ||
"factories = {\"Slider factory\": slider_factory}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ac5f292c-581f-4ad7-9eb5-29b677278307", | ||
"metadata": {}, | ||
"source": [ | ||
"### Create an empty dashboard with factory" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "05e001ae-28a9-410d-ba96-33aaa92576a2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "11166ad0399740f8a64fc5e9b863f376", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"FlexLayout(children={'Linked slider': FloatSlider(value=0.0, description='Linked slider')}, layout_config={'bo…" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"FlexLayout(widgets, factories=factories, style={'height':'300px'})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e53da48e-56f5-4413-bc40-1e95588b74f9", | ||
"metadata": {}, | ||
"source": [ | ||
"### Load dashboard from template" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ef565dce-efc6-4481-9ae1-6acd2257a01f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"FlexLayout(widgets, factories=factories, style={'height':'300px'}, template = 'widget_factory.json')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6219ba62-23b8-441f-843a-1e650243bba5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"global": {"tabSetEnableClose": true, "tabSetTabLocation": "bottom"}, "borders": [], "layout": {"type": "row", "id": "#1", "children": [{"type": "tabset", "id": "#2", "children": [{"type": "tab", "id": "#3", "name": "New section ", "component": "sub", "config": {"model": {"global": {"tabSetEnableClose": true}, "borders": [], "layout": {"type": "row", "id": "#1", "children": [{"type": "row", "id": "#1399287c-e9b4-493c-abb3-54168c374352", "weight": 50, "children": [{"type": "tabset", "id": "#d95f9720-fb3d-43bb-a10f-10a4c0a61807", "weight": 50, "children": [{"type": "tab", "id": "#6d9d8b09-f17b-43ef-bb53-fbf936f74da0", "name": "Linked slider", "component": "Widget", "config": {"layoutID": "#3"}}]}, {"type": "tabset", "id": "#061a7542-6b94-454e-bb90-7a6d0bed7f1e", "weight": 50, "children": [{"type": "tab", "id": "#f95061fa-87c5-476e-98a3-5e7bf447deba", "name": "Linked slider", "component": "Widget", "config": {"layoutID": "#3"}}]}]}, {"type": "row", "id": "#69568e98-a2e4-4643-8cf2-2b3451718b15", "weight": 50, "children": [{"type": "tabset", "id": "#fab8e962-3886-47c3-9697-9ce8472ae8fc", "weight": 50, "children": [{"type": "tab", "id": "#6823abc0-557b-4720-b99b-a093cdd2b3a4", "name": "Slider factory", "component": "Widget", "config": {"layoutID": "#3", "extraData": {"label": "Slider 1", "value": "10"}}}]}, {"type": "tabset", "id": "#f5e77e9e-863d-443c-88cf-fe5457874302", "weight": 50, "children": [{"type": "tab", "id": "#cfa489e0-249c-4fa7-bf15-0dc54619d8d9", "name": "Slider factory", "component": "Widget", "config": {"layoutID": "#3", "extraData": {"label": "Slider 2", "value": "20"}}}], "active": true}]}]}}}}], "active": true}]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.