|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [ |
| 8 | + { |
| 9 | + "data": { |
| 10 | + "application/vnd.jupyter.widget-view+json": { |
| 11 | + "model_id": "50782ddbb20d4554b3177cd46a259adf", |
| 12 | + "version_major": 2, |
| 13 | + "version_minor": 0 |
| 14 | + }, |
| 15 | + "text/plain": [ |
| 16 | + "IntSlider(value=50, description='Slider:')" |
| 17 | + ] |
| 18 | + }, |
| 19 | + "metadata": {}, |
| 20 | + "output_type": "display_data" |
| 21 | + }, |
| 22 | + { |
| 23 | + "data": { |
| 24 | + "application/vnd.jupyter.widget-view+json": { |
| 25 | + "model_id": "2798f6e7c7b34b76be50958d5d60fd5c", |
| 26 | + "version_major": 2, |
| 27 | + "version_minor": 0 |
| 28 | + }, |
| 29 | + "text/plain": [ |
| 30 | + "Button(description='Click Me', style=ButtonStyle())" |
| 31 | + ] |
| 32 | + }, |
| 33 | + "metadata": {}, |
| 34 | + "output_type": "display_data" |
| 35 | + }, |
| 36 | + { |
| 37 | + "data": { |
| 38 | + "application/vnd.jupyter.widget-view+json": { |
| 39 | + "model_id": "e4b5b3a74ffd4947912da1c191a393c0", |
| 40 | + "version_major": 2, |
| 41 | + "version_minor": 0 |
| 42 | + }, |
| 43 | + "text/plain": [ |
| 44 | + "Output()" |
| 45 | + ] |
| 46 | + }, |
| 47 | + "metadata": {}, |
| 48 | + "output_type": "display_data" |
| 49 | + } |
| 50 | + ], |
| 51 | + "source": [ |
| 52 | + "import ipywidgets as widgets\n", |
| 53 | + "from IPython.display import display\n", |
| 54 | + "\n", |
| 55 | + "slider = widgets.IntSlider(value=50, min=0, max=100, description=\"Slider:\")\n", |
| 56 | + "\n", |
| 57 | + "button = widgets.Button(description=\"Click Me\")\n", |
| 58 | + "\n", |
| 59 | + "output = widgets.Output()\n", |
| 60 | + "\n", |
| 61 | + "def on_button_click(b):\n", |
| 62 | + " with output:\n", |
| 63 | + " print(\"Button Clicked!\")\n", |
| 64 | + "\n", |
| 65 | + "button.on_click(on_button_click)\n", |
| 66 | + "\n", |
| 67 | + "display(slider, button, output)" |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + "cell_type": "code", |
| 72 | + "execution_count": null, |
| 73 | + "metadata": {}, |
| 74 | + "outputs": [], |
| 75 | + "source": [] |
| 76 | + } |
| 77 | + ], |
| 78 | + "metadata": { |
| 79 | + "kernelspec": { |
| 80 | + "display_name": "Python 3 (ipykernel)", |
| 81 | + "language": "python", |
| 82 | + "name": "python3" |
| 83 | + }, |
| 84 | + "language_info": { |
| 85 | + "codemirror_mode": { |
| 86 | + "name": "ipython", |
| 87 | + "version": 3 |
| 88 | + }, |
| 89 | + "file_extension": ".py", |
| 90 | + "mimetype": "text/x-python", |
| 91 | + "name": "python", |
| 92 | + "nbconvert_exporter": "python", |
| 93 | + "pygments_lexer": "ipython3", |
| 94 | + "version": "3.12.7" |
| 95 | + } |
| 96 | + }, |
| 97 | + "nbformat": 4, |
| 98 | + "nbformat_minor": 4 |
| 99 | +} |
0 commit comments