1
+ from datetime import datetime
2
+ import pytest
3
+ import dash
4
+ import dash_core_components as dcc
5
+ import dash_html_components as html
6
+
7
+
8
+ OPTIONS = [
9
+ {"label" : "New York City" , "value" : "NYC" },
10
+ {"label" : u"Montréal" , "value" : "MTL" },
11
+ {"label" : "San Francisco" , "value" : "SF" },
12
+ {"label" : u"北京" , "value" : u"帝都" },
13
+ {"label" : u"臺北" , "value" : u"天龍國" },
14
+ ]
15
+
16
+
17
+ @pytest .fixture (scope = "module" )
18
+ def platter_app ():
19
+ app = dash .Dash (__name__ )
20
+
21
+ app .layout = html .Div (
22
+ [
23
+ html .Div (id = "waitfor" ),
24
+ html .Label ("Upload" ),
25
+ dcc .Upload (),
26
+ html .Label ("Horizontal Tabs" ),
27
+ dcc .Tabs (
28
+ id = "tabs" ,
29
+ children = [
30
+ dcc .Tab (
31
+ label = "Tab one" ,
32
+ className = "test" ,
33
+ style = {"border" : "1px solid magenta" },
34
+ children = [html .Div (["Test" ])],
35
+ ),
36
+ dcc .Tab (
37
+ label = "Tab two" ,
38
+ children = [
39
+ html .Div (
40
+ [
41
+ html .H1 ("This is the content in tab 2" ),
42
+ html .P ("A graph here would be nice!" ),
43
+ ]
44
+ )
45
+ ],
46
+ id = "tab-one" ,
47
+ ),
48
+ dcc .Tab (
49
+ label = "Tab three" ,
50
+ children = [
51
+ html .Div ([html .H1 ("This is the content in tab 3" )])
52
+ ],
53
+ ),
54
+ ],
55
+ style = {"fontFamily" : "system-ui" },
56
+ content_style = {"border" : "1px solid #d6d6d6" , "padding" : "44px" },
57
+ parent_style = {"maxWidth" : "1000px" , "margin" : "0 auto" },
58
+ ),
59
+ html .Label ("Vertical Tabs" ),
60
+ dcc .Tabs (
61
+ id = "tabs1" ,
62
+ vertical = True ,
63
+ children = [
64
+ dcc .Tab (label = "Tab one" , children = [html .Div (["Test" ])]),
65
+ dcc .Tab (
66
+ label = "Tab two" ,
67
+ children = [
68
+ html .Div (
69
+ [
70
+ html .H1 ("This is the content in tab 2" ),
71
+ html .P ("A graph here would be nice!" ),
72
+ ]
73
+ )
74
+ ],
75
+ ),
76
+ dcc .Tab (
77
+ label = "Tab three" ,
78
+ children = [
79
+ html .Div ([html .H1 ("This is the content in tab 3" )])
80
+ ],
81
+ ),
82
+ ],
83
+ ),
84
+ html .Label ("Dropdown" ),
85
+ dcc .Dropdown (options = OPTIONS , value = "MTL" , id = "dropdown" ),
86
+ html .Label ("Multi-Select Dropdown" ),
87
+ dcc .Dropdown (options = OPTIONS , value = ["MTL" , "SF" ], multi = True ),
88
+ html .Label ("Radio Items" ),
89
+ dcc .RadioItems (options = OPTIONS , value = "MTL" ),
90
+ html .Label ("Checkboxes" ),
91
+ dcc .Checklist (options = OPTIONS , value = ["MTL" , "SF" ]),
92
+ html .Label ("Text Input" ),
93
+ dcc .Input (value = "" , placeholder = "type here" , id = "textinput" ),
94
+ html .Label ("Disabled Text Input" ),
95
+ dcc .Input (
96
+ value = "disabled" ,
97
+ type = "text" ,
98
+ id = "disabled-textinput" ,
99
+ disabled = True ,
100
+ ),
101
+ html .Label ("Slider" ),
102
+ dcc .Slider (
103
+ min = 0 ,
104
+ max = 9 ,
105
+ marks = {
106
+ i : "Label {}" .format (i ) if i == 1 else str (i )
107
+ for i in range (1 , 6 )
108
+ },
109
+ value = 5 ,
110
+ ),
111
+ html .Label ("Graph" ),
112
+ dcc .Graph (
113
+ id = "graph" ,
114
+ figure = {
115
+ "data" : [{"x" : [1 , 2 , 3 ], "y" : [4 , 1 , 4 ]}],
116
+ "layout" : {"title" : u"北京" },
117
+ },
118
+ ),
119
+ html .Div (
120
+ [
121
+ html .Label ("DatePickerSingle" ),
122
+ dcc .DatePickerSingle (
123
+ id = "date-picker-single" , date = datetime (1997 , 5 , 10 )
124
+ ),
125
+ html .Div (
126
+ [
127
+ html .Label ("DatePickerSingle - empty input" ),
128
+ dcc .DatePickerSingle (),
129
+ ],
130
+ id = "dt-single-no-date-value" ,
131
+ ),
132
+ html .Div (
133
+ [
134
+ html .Label (
135
+ "DatePickerSingle - initial visible month (May 97)"
136
+ ),
137
+ dcc .DatePickerSingle (
138
+ initial_visible_month = datetime (1997 , 5 , 10 )
139
+ ),
140
+ ],
141
+ id = "dt-single-no-date-value-init-month" ,
142
+ ),
143
+ ]
144
+ ),
145
+ html .Div (
146
+ [
147
+ html .Label ("DatePickerRange" ),
148
+ dcc .DatePickerRange (
149
+ id = "date-picker-range" ,
150
+ start_date_id = "startDate" ,
151
+ end_date_id = "endDate" ,
152
+ start_date = datetime (1997 , 5 , 3 ),
153
+ end_date_placeholder_text = "Select a date!" ,
154
+ ),
155
+ html .Div (
156
+ [
157
+ html .Label ("DatePickerRange - empty input" ),
158
+ dcc .DatePickerRange (
159
+ start_date_id = "startDate" ,
160
+ end_date_id = "endDate" ,
161
+ start_date_placeholder_text = "Start date" ,
162
+ end_date_placeholder_text = "End date" ,
163
+ ),
164
+ ],
165
+ id = "dt-range-no-date-values" ,
166
+ ),
167
+ html .Div (
168
+ [
169
+ html .Label (
170
+ "DatePickerRange - initial visible month (May 97)"
171
+ ),
172
+ dcc .DatePickerRange (
173
+ start_date_id = "startDate" ,
174
+ end_date_id = "endDate" ,
175
+ start_date_placeholder_text = "Start date" ,
176
+ end_date_placeholder_text = "End date" ,
177
+ initial_visible_month = datetime (1997 , 5 , 10 ),
178
+ ),
179
+ ],
180
+ id = "dt-range-no-date-values-init-month" ,
181
+ ),
182
+ ]
183
+ ),
184
+ html .Label ("TextArea" ),
185
+ dcc .Textarea (
186
+ placeholder = "Enter a value... 北京" , style = {"width" : "100%" }
187
+ ),
188
+ html .Label ("Markdown" ),
189
+ dcc .Markdown (
190
+ """
191
+ #### Dash and Markdown
192
+
193
+ Dash supports [Markdown](https://rexxars.github.io/react-markdown/).
194
+
195
+ Markdown is a simple way to write and format text.
196
+ It includes a syntax for things like **bold text** and *italics*,
197
+ [links](https://rexxars.github.io/react-markdown/), inline `code` snippets, lists,
198
+ quotes, and more.
199
+
200
+ 1. Links are auto-rendered: https://dash.plot.ly.
201
+ 2. This uses ~commonmark~ GitHub flavored markdown.
202
+
203
+ Tables are also supported:
204
+
205
+ | First Header | Second Header |
206
+ | ------------- | ------------- |
207
+ | Content Cell | Content Cell |
208
+ | Content Cell | Content Cell |
209
+
210
+ 北京
211
+ """ .replace (
212
+ " " , ""
213
+ )
214
+ ),
215
+ dcc .Markdown (["# Line one" , "## Line two" ]),
216
+ dcc .Markdown (),
217
+ dcc .Markdown (
218
+ """
219
+ ```py
220
+ import python
221
+ print(3)
222
+ ```"""
223
+ ),
224
+ dcc .Markdown (["```py" , "import python" , "print(3)" , "```" ]),
225
+ dcc .Markdown (),
226
+ ]
227
+ )
228
+
229
+ yield app
0 commit comments