{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "flex_subtitle = \"built using jupyter-flex\"\n", "flex_external_link = \"https://github.com/danielfrg/jupyter-flex/blob/master/examples/illusionist/multiplier.ipynb\"\n", "\n", "flex_title = \"Illusionist multiplier\"\n", "flex_show_source = True" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "sidebar" ] }, "source": [ "## Sidebar" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2020-08-30T18:50:30.688800Z", "iopub.status.busy": "2020-08-30T18:50:30.688026Z", "iopub.status.idle": "2020-08-30T18:50:30.716124Z", "shell.execute_reply": "2020-08-30T18:50:30.716586Z" }, "tags": [ "source" ] }, "outputs": [], "source": [ "import ipywidgets as widgets" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2020-08-30T18:50:30.726728Z", "iopub.status.busy": "2020-08-30T18:50:30.725988Z", "iopub.status.idle": "2020-08-30T18:50:30.730827Z", "shell.execute_reply": "2020-08-30T18:50:30.730300Z" }, "tags": [ "body" ] }, "outputs": [], "source": [ "slider = widgets.IntSlider(description=\"Number\", max=10, value=5)\n", "slider" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2020-08-30T18:50:30.736574Z", "iopub.status.busy": "2020-08-30T18:50:30.735884Z", "iopub.status.idle": "2020-08-30T18:50:30.741724Z", "shell.execute_reply": "2020-08-30T18:50:30.742199Z" }, "tags": [ "body" ] }, "outputs": [], "source": [ "bounded_int = widgets.BoundedIntText(description=\"Multiplier\", value=2, min=0, max=5)\n", "bounded_int" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Output" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2020-08-30T18:50:30.749205Z", "iopub.status.busy": "2020-08-30T18:50:30.747685Z", "iopub.status.idle": "2020-08-30T18:50:30.752686Z", "shell.execute_reply": "2020-08-30T18:50:30.753090Z" }, "tags": [ "body" ] }, "outputs": [], "source": [ "multiplication = widgets.Label()\n", "multiplication" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2020-08-30T18:50:30.757003Z", "iopub.status.busy": "2020-08-30T18:50:30.756455Z", "iopub.status.idle": "2020-08-30T18:50:30.758239Z", "shell.execute_reply": "2020-08-30T18:50:30.758595Z" }, "tags": [ "source" ] }, "outputs": [], "source": [ "def update_lbl(args):\n", " multiplication.value = str(slider.value * bounded_int.value)\n", "\n", "update_lbl(None)\n", " \n", "slider.observe(update_lbl, 'value')\n", "bounded_int.observe(update_lbl, 'value')" ] }, { "cell_type": "code", "execution_count": null, "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.8.10" }, "widgets": { "application/vnd.illusionist.widget-onchange+json": { "all_widgets": [ "0819b6672edc432a99a3922e3dadd0a4", "95f86e6da178437d86bfb4eb487d62a2", "d66b772861ee432d90339c029ae6cad0" ], "control_widgets": [ "0819b6672edc432a99a3922e3dadd0a4", "95f86e6da178437d86bfb4eb487d62a2" ], "onchange": { "d66b772861ee432d90339c029ae6cad0": { "affected_by": [ "95f86e6da178437d86bfb4eb487d62a2", "0819b6672edc432a99a3922e3dadd0a4" ], "values": { "0,0": "0", "0,1": "0", "0,10": "0", "0,2": "0", "0,3": "0", "0,4": "0", "0,5": "0", "0,6": "0", "0,7": "0", "0,8": "0", "0,9": "0", "1,0": "0", "1,1": "1", "1,10": "10", "1,2": "2", "1,3": "3", "1,4": "4", "1,5": "5", "1,6": "6", "1,7": "7", "1,8": "8", "1,9": "9", "2,0": "0", "2,1": "2", "2,10": "20", "2,2": "4", "2,3": "6", "2,4": "8", "2,5": "10", "2,6": "12", "2,7": "14", "2,8": "16", "2,9": "18", "3,0": "0", "3,1": "3", "3,10": "30", "3,2": "6", "3,3": "9", "3,4": "12", "3,5": "15", "3,6": "18", "3,7": "21", "3,8": "24", "3,9": "27", "4,0": "0", "4,1": "4", "4,10": "40", "4,2": "8", "4,3": "12", "4,4": "16", "4,5": "20", "4,6": "24", "4,7": "28", "4,8": "32", "4,9": "36", "5,0": "0", "5,1": "5", "5,10": "50", "5,2": "10", "5,3": "15", "5,4": "20", "5,5": "25", "5,6": "30", "5,7": "35", "5,8": "40", "5,9": "45" } } }, "version_major": 1, "version_minor": 0 }, "application/vnd.jupyter.widget-state+json": { "state": { "0819b6672edc432a99a3922e3dadd0a4": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "IntSliderModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "IntSliderModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "IntSliderView", "continuous_update": true, "description": "Number", "description_tooltip": null, "disabled": false, "layout": "IPY_MODEL_29a0d5c3c28a47c39c3216707a3d44cc", "max": 10, "min": 0, "orientation": "horizontal", "readout": true, "readout_format": "d", "step": 1, "style": "IPY_MODEL_d1ec75c35bab415f965c7ae3c93ba7bc", "value": 5 } }, "26d3d8594ebc4722920952186597e2b5": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "282ed36001934dc79494015ca2cae8c0": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "29a0d5c3c28a47c39c3216707a3d44cc": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "4b0af07038674feead4d87c994cb1e5b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "80c4d66b79374f5f8db72e8d94be94f4": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "95f86e6da178437d86bfb4eb487d62a2": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "BoundedIntTextModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "BoundedIntTextModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "IntTextView", "continuous_update": false, "description": "Multiplier", "description_tooltip": null, "disabled": false, "layout": "IPY_MODEL_282ed36001934dc79494015ca2cae8c0", "max": 5, "min": 0, "step": 1, "style": "IPY_MODEL_4b0af07038674feead4d87c994cb1e5b", "value": 2 } }, "d1ec75c35bab415f965c7ae3c93ba7bc": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "SliderStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "SliderStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "", "handle_color": null } }, "d66b772861ee432d90339c029ae6cad0": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "LabelModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "LabelModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "LabelView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_26d3d8594ebc4722920952186597e2b5", "placeholder": "​", "style": "IPY_MODEL_80c4d66b79374f5f8db72e8d94be94f4", "value": "10" } } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }