{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b05d39ae", "metadata": {}, "outputs": [], "source": [ "import mercury as mr" ] }, { "cell_type": "code", "execution_count": 2, "id": "11dd0e47", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Checkbox demo\",\n \"description\": \"Show Checkbox widget usage\",\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.2-rand39799366\"\n}", "text/html": [ "

Mercury Application

This output won't appear in the web app." ], "text/plain": [ "mercury.App" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# setup app properies\n", "app = mr.App(title=\"Checkbox\", description=\"Show Checkbox widget usage\", show_code=True)" ] }, { "cell_type": "code", "execution_count": 3, "id": "841c5232", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"Checkbox\",\n \"value\": true,\n \"label\": \"Switch me\",\n \"model_id\": \"204f4edc6b9a4c418f8519b4037ef0be\",\n \"code_uid\": \"Checkbox.0.40.11.2-rand5e9a7097\",\n \"url_key\": \"flag\",\n \"disabled\": false,\n \"hidden\": false\n}", "application/vnd.jupyter.widget-view+json": { "model_id": "204f4edc6b9a4c418f8519b4037ef0be", "version_major": 2, "version_minor": 0 }, "text/plain": [ "mercury.Checkbox" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# add checkbox\n", "my_flag = mr.Checkbox(value=True, label=\"Switch me\", url_key=\"flag\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "d751ba3d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Checkbox is ON\n" ] } ], "source": [ "# read checkbox value\n", "if my_flag.value:\n", " print(\"Checkbox is ON\")\n", "else:\n", " print(\"Checkbox is OFF\")" ] }, { "cell_type": "code", "execution_count": null, "id": "3cd671ad", "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 }