Spaces:
Runtime error
Runtime error
Upload 5 files
Browse filesFiles changed (5)
- checkbox.ipynbAdded+117
- multiselect.ipynbAdded+106
- range.ipynbAdded+106
- slider.ipynbAdded+106
- text.ipynbAdded+103
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117{ "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": [ "<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>" ], "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}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "157994cc", "metadata": {}, "outputs": [], "source": [ "import mercury as mr" ] }, { "cell_type": "code", "execution_count": 2, "id": "f2970759", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"MultiSelect\",\n \"description\": \"Demo of MutiSelect 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-rand52ff8045\"\n}", "text/html": [ "<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>" ], "text/plain": [ "mercury.App" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "app = mr.App(title=\"MultiSelect\", description=\"Demo of MutiSelect widget\", show_code=True)" ] }, { "cell_type": "code", "execution_count": 3, "id": "e799cfd3", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"MultiSelect\",\n \"value\": [\n \"a\",\n \"b\"\n ],\n \"choices\": [\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\"\n ],\n \"label\": \"Please select letters\",\n \"model_id\": \"4bd323cd1655481fbda0eda5adef7a61\",\n \"code_uid\": \"MultiSelect.0.40.16.1-rand84903bec\",\n \"url_key\": \"selected\",\n \"disabled\": false,\n \"hidden\": false\n}", "application/vnd.jupyter.widget-view+json": { "model_id": "4bd323cd1655481fbda0eda5adef7a61", "version_major": 2, "version_minor": 0 }, "text/plain": [ "mercury.MultiSelect" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "selected = mr.MultiSelect(label=\"Please select letters\", \n", " value=[\"a\", \"b\"], \n", " choices=[\"a\", \"b\", \"c\", \"d\", \"e\"],\n", " url_key=\"selected\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "86a9e273", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['a', 'b']\n" ] } ], "source": [ "print(selected.value)" ] } ], "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}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106{ "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": [ "<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>" ], "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}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106{ "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-rand1686cc3b\"\n}", "text/html": [ "<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>" ], "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\": \"e72d431e26ba4b39b0dd87af3f159134\",\n \"code_uid\": \"Slider.0.40.26.2-rand67b7c60c\",\n \"url_key\": \"slider\",\n \"disabled\": false,\n \"hidden\": false\n}", "application/vnd.jupyter.widget-view+json": { "model_id": "e72d431e26ba4b39b0dd87af3f159134", "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}\")" ] } ], "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}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "164f76b7", "metadata": {}, "outputs": [], "source": [ "import mercury as mr" ] }, { "cell_type": "code", "execution_count": 2, "id": "17c4a3fd", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Text\",\n \"description\": \"Demo of Text 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-rande67e72ed\"\n}", "text/html": [ "<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>" ], "text/plain": [ "mercury.App" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "app = mr.App(title=\"Text\", description=\"Demo of Text widget\", show_code=True)" ] }, { "cell_type": "code", "execution_count": 3, "id": "f3c12349", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"Piotr\",\n \"rows\": 1,\n \"label\": \"What is your name?\",\n \"model_id\": \"9dc1a4398f7a4b96abb2077f790c4f47\",\n \"code_uid\": \"Text.0.40.15.1-rande827c6e5\",\n \"url_key\": \"name\",\n \"disabled\": false,\n \"hidden\": false\n}", "application/vnd.jupyter.widget-view+json": { "model_id": "9dc1a4398f7a4b96abb2077f790c4f47", "version_major": 2, "version_minor": 0 }, "text/plain": [ "mercury.Text" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "name = mr.Text(value=\"Piotr\", label=\"What is your name?\", rows=1, url_key=\"name\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "6dadd338", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello Piotr!\n" ] } ], "source": [ "print(f\"Hello {name.value}!\")" ] } ], "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}checkbox.ipynbAdded+117
multiselect.ipynbAdded+106
range.ipynbAdded+106
slider.ipynbAdded+106
text.ipynbAdded+103