Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- slider.ipynb +114 -0
- text.ipynb +103 -0
slider.ipynb
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"id": "b2377049",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [],
|
| 9 |
+
"source": [
|
| 10 |
+
"import mercury as mr"
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"cell_type": "code",
|
| 15 |
+
"execution_count": 2,
|
| 16 |
+
"id": "e2a239f0",
|
| 17 |
+
"metadata": {},
|
| 18 |
+
"outputs": [
|
| 19 |
+
{
|
| 20 |
+
"data": {
|
| 21 |
+
"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}",
|
| 22 |
+
"text/html": [
|
| 23 |
+
"<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"
|
| 24 |
+
],
|
| 25 |
+
"text/plain": [
|
| 26 |
+
"mercury.App"
|
| 27 |
+
]
|
| 28 |
+
},
|
| 29 |
+
"metadata": {},
|
| 30 |
+
"output_type": "display_data"
|
| 31 |
+
}
|
| 32 |
+
],
|
| 33 |
+
"source": [
|
| 34 |
+
"app = mr.App(title=\"Slider\", description=\"Demo of Slider widget\", show_code=True)"
|
| 35 |
+
]
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"cell_type": "code",
|
| 39 |
+
"execution_count": 3,
|
| 40 |
+
"id": "b71b36bd",
|
| 41 |
+
"metadata": {},
|
| 42 |
+
"outputs": [
|
| 43 |
+
{
|
| 44 |
+
"data": {
|
| 45 |
+
"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}",
|
| 46 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 47 |
+
"model_id": "a0f31a2c14054f65a330d73d85587630",
|
| 48 |
+
"version_major": 2,
|
| 49 |
+
"version_minor": 0
|
| 50 |
+
},
|
| 51 |
+
"text/plain": [
|
| 52 |
+
"mercury.Slider"
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
"metadata": {},
|
| 56 |
+
"output_type": "display_data"
|
| 57 |
+
}
|
| 58 |
+
],
|
| 59 |
+
"source": [
|
| 60 |
+
"# add widget\n",
|
| 61 |
+
"your_slider = mr.Slider(value=0, min=0, max=10, label=\"Your favourite number\", \n",
|
| 62 |
+
" step=1, url_key=\"slider\")"
|
| 63 |
+
]
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"cell_type": "code",
|
| 67 |
+
"execution_count": 4,
|
| 68 |
+
"id": "13e16734",
|
| 69 |
+
"metadata": {},
|
| 70 |
+
"outputs": [
|
| 71 |
+
{
|
| 72 |
+
"name": "stdout",
|
| 73 |
+
"output_type": "stream",
|
| 74 |
+
"text": [
|
| 75 |
+
"Your value is 0\n"
|
| 76 |
+
]
|
| 77 |
+
}
|
| 78 |
+
],
|
| 79 |
+
"source": [
|
| 80 |
+
"# access widget value in the code\n",
|
| 81 |
+
"print(f\"Your value is {your_slider.value}\")"
|
| 82 |
+
]
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"cell_type": "code",
|
| 86 |
+
"execution_count": null,
|
| 87 |
+
"id": "71903c98",
|
| 88 |
+
"metadata": {},
|
| 89 |
+
"outputs": [],
|
| 90 |
+
"source": []
|
| 91 |
+
}
|
| 92 |
+
],
|
| 93 |
+
"metadata": {
|
| 94 |
+
"kernelspec": {
|
| 95 |
+
"display_name": "mex",
|
| 96 |
+
"language": "python",
|
| 97 |
+
"name": "mex"
|
| 98 |
+
},
|
| 99 |
+
"language_info": {
|
| 100 |
+
"codemirror_mode": {
|
| 101 |
+
"name": "ipython",
|
| 102 |
+
"version": 3
|
| 103 |
+
},
|
| 104 |
+
"file_extension": ".py",
|
| 105 |
+
"mimetype": "text/x-python",
|
| 106 |
+
"name": "python",
|
| 107 |
+
"nbconvert_exporter": "python",
|
| 108 |
+
"pygments_lexer": "ipython3",
|
| 109 |
+
"version": "3.8.10"
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
"nbformat": 4,
|
| 113 |
+
"nbformat_minor": 5
|
| 114 |
+
}
|
text.ipynb
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"id": "164f76b7",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [],
|
| 9 |
+
"source": [
|
| 10 |
+
"import mercury as mr"
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"cell_type": "code",
|
| 15 |
+
"execution_count": 2,
|
| 16 |
+
"id": "17c4a3fd",
|
| 17 |
+
"metadata": {},
|
| 18 |
+
"outputs": [
|
| 19 |
+
{
|
| 20 |
+
"data": {
|
| 21 |
+
"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}",
|
| 22 |
+
"text/html": [
|
| 23 |
+
"<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"
|
| 24 |
+
],
|
| 25 |
+
"text/plain": [
|
| 26 |
+
"mercury.App"
|
| 27 |
+
]
|
| 28 |
+
},
|
| 29 |
+
"metadata": {},
|
| 30 |
+
"output_type": "display_data"
|
| 31 |
+
}
|
| 32 |
+
],
|
| 33 |
+
"source": [
|
| 34 |
+
"app = mr.App(title=\"Text\", description=\"Demo of Text widget\", show_code=True)"
|
| 35 |
+
]
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"cell_type": "code",
|
| 39 |
+
"execution_count": 3,
|
| 40 |
+
"id": "f3c12349",
|
| 41 |
+
"metadata": {},
|
| 42 |
+
"outputs": [
|
| 43 |
+
{
|
| 44 |
+
"data": {
|
| 45 |
+
"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}",
|
| 46 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 47 |
+
"model_id": "9dc1a4398f7a4b96abb2077f790c4f47",
|
| 48 |
+
"version_major": 2,
|
| 49 |
+
"version_minor": 0
|
| 50 |
+
},
|
| 51 |
+
"text/plain": [
|
| 52 |
+
"mercury.Text"
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
"metadata": {},
|
| 56 |
+
"output_type": "display_data"
|
| 57 |
+
}
|
| 58 |
+
],
|
| 59 |
+
"source": [
|
| 60 |
+
"name = mr.Text(value=\"Piotr\", label=\"What is your name?\", rows=1, url_key=\"name\")"
|
| 61 |
+
]
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"cell_type": "code",
|
| 65 |
+
"execution_count": 4,
|
| 66 |
+
"id": "6dadd338",
|
| 67 |
+
"metadata": {},
|
| 68 |
+
"outputs": [
|
| 69 |
+
{
|
| 70 |
+
"name": "stdout",
|
| 71 |
+
"output_type": "stream",
|
| 72 |
+
"text": [
|
| 73 |
+
"Hello Piotr!\n"
|
| 74 |
+
]
|
| 75 |
+
}
|
| 76 |
+
],
|
| 77 |
+
"source": [
|
| 78 |
+
"print(f\"Hello {name.value}!\")"
|
| 79 |
+
]
|
| 80 |
+
}
|
| 81 |
+
],
|
| 82 |
+
"metadata": {
|
| 83 |
+
"kernelspec": {
|
| 84 |
+
"display_name": "mex",
|
| 85 |
+
"language": "python",
|
| 86 |
+
"name": "mex"
|
| 87 |
+
},
|
| 88 |
+
"language_info": {
|
| 89 |
+
"codemirror_mode": {
|
| 90 |
+
"name": "ipython",
|
| 91 |
+
"version": 3
|
| 92 |
+
},
|
| 93 |
+
"file_extension": ".py",
|
| 94 |
+
"mimetype": "text/x-python",
|
| 95 |
+
"name": "python",
|
| 96 |
+
"nbconvert_exporter": "python",
|
| 97 |
+
"pygments_lexer": "ipython3",
|
| 98 |
+
"version": "3.8.10"
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
"nbformat": 4,
|
| 102 |
+
"nbformat_minor": 5
|
| 103 |
+
}
|