File size: 2,776 Bytes
bf1d125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{
 "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
}