{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0954eef1", "metadata": {}, "outputs": [], "source": [ "import mercury as mr" ] }, { "cell_type": "code", "execution_count": 2, "id": "e49cd34d", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Range\",\n \"description\": \"Range widget demo\",\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-rand8e094375\"\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=\"Range\", description=\"Range widget demo\", show_code=True)" ] }, { "cell_type": "code", "execution_count": 3, "id": "412fce10", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"Range\",\n \"value\": [\n 1,\n 6\n ],\n \"min\": 0,\n \"max\": 10,\n \"step\": 1,\n \"label\": \"Your favourite range\",\n \"model_id\": \"c7bb17abbf4b49c4a5b7edf2c971803e\",\n \"code_uid\": \"Range.0.40.30.2-randc2556550\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}", "application/vnd.jupyter.widget-view+json": { "model_id": "c7bb17abbf4b49c4a5b7edf2c971803e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "mercury.Range" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# add range widget\n", "your_range = mr.Range(value=[1, 6], min=0, max=10, label=\"Your favourite range\", \n", " step=1, url_key=\"my-range\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "4c3147bc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Your range starts at 1 ends at 6\n" ] } ], "source": [ "# access widget value in the code\n", "print(f\"Your range starts at {your_range.value[0]} ends at {your_range.value[1]}\")" ] } ], "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 }