{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b2377049", "metadata": {}, "outputs": [], "source": [ "import mercury as mr" ] }, { "cell_type": "code", "execution_count": 2, "id": "e2a239f0", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Slider\",\n \"description\": \"Demo of Slider widget\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-randc5d03c05\"\n}", "text/html": [ "

Mercury Application

This output won't appear in the web app." ], "text/plain": [ "mercury.App" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "app = mr.App(title=\"Slider\", description=\"Demo of Slider widget\", show_code=True)" ] }, { "cell_type": "code", "execution_count": 3, "id": "b71b36bd", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"Slider\",\n \"value\": 0,\n \"min\": 0,\n \"max\": 10,\n \"step\": 1,\n \"label\": \"Your favourite number\",\n \"model_id\": \"a0f31a2c14054f65a330d73d85587630\",\n \"code_uid\": \"Slider.0.40.26.2-rand37abec4b\",\n \"url_key\": \"slider\",\n \"disabled\": false,\n \"hidden\": false\n}", "application/vnd.jupyter.widget-view+json": { "model_id": "a0f31a2c14054f65a330d73d85587630", "version_major": 2, "version_minor": 0 }, "text/plain": [ "mercury.Slider" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# add widget\n", "your_slider = mr.Slider(value=0, min=0, max=10, label=\"Your favourite number\", \n", " step=1, url_key=\"slider\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "13e16734", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Your value is 0\n" ] } ], "source": [ "# access widget value in the code\n", "print(f\"Your value is {your_slider.value}\")" ] }, { "cell_type": "code", "execution_count": null, "id": "71903c98", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "mex", "language": "python", "name": "mex" }, "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" } }, "nbformat": 4, "nbformat_minor": 5 }