{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "a4f12e16-80e4-4488-89c0-16c93651de93", "metadata": {}, "outputs": [], "source": [ "import ipywidgets as widgets\n", "import IPython\n", "from IPython.display import display" ] }, { "cell_type": "code", "execution_count": null, "id": "bbae1b8c-92bc-44e5-9634-1a68b64daec4", "metadata": {}, "outputs": [], "source": [ "widgets.__version__" ] }, { "cell_type": "code", "execution_count": null, "id": "50393d6b-e944-41bc-a5ff-d0b67d98e8de", "metadata": {}, "outputs": [], "source": [ "IPython.__version__" ] }, { "cell_type": "code", "execution_count": null, "id": "03b30441-f6fe-4915-a75f-5d0af62e1a5a", "metadata": {}, "outputs": [], "source": [ "slider = widgets.FloatSlider(min=0, max=1)\n", "button = widgets.Button(description=\"Change value\", readout=True)\n", "\n", "def change(_button):\n", " slider.value = 0.7000001\n", "\n", "button.on_click(change)\n", "\n", "display(slider)\n", "display(button)" ] }, { "cell_type": "code", "execution_count": null, "id": "9a4025be-75e7-4b6f-bf33-7b48ba987374", "metadata": {}, "outputs": [], "source": [ "print(slider.value)" ] } ], "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.12.5" } }, "nbformat": 4, "nbformat_minor": 5 }