##// END OF EJS Templates
Updated alignment example to show pack&align
Jonathan Frederic -
Show More
@@ -1,5 +1,11 b''
1 1 {
2 2 "metadata": {
3 "cell_tags": [
4 [
5 "<None>",
6 null
7 ]
8 ],
3 9 "name": ""
4 10 },
5 11 "nbformat": 3,
@@ -22,70 +28,70 b''
22 28 "outputs": [
23 29 {
24 30 "javascript": [
25 "$.getScript(\"../static/notebook/js/widgets/bool.js\");"
31 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/button.js\");"
26 32 ],
27 33 "metadata": {},
28 34 "output_type": "display_data"
29 35 },
30 36 {
31 37 "javascript": [
32 "$.getScript(\"../static/notebook/js/widgets/int_range.js\");"
38 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int_range.js\");"
33 39 ],
34 40 "metadata": {},
35 41 "output_type": "display_data"
36 42 },
37 43 {
38 44 "javascript": [
39 "$.getScript(\"../static/notebook/js/widgets/int.js\");"
45 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/string.js\");"
40 46 ],
41 47 "metadata": {},
42 48 "output_type": "display_data"
43 49 },
44 50 {
45 51 "javascript": [
46 "$.getScript(\"../static/notebook/js/widgets/selection.js\");"
52 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/multicontainer.js\");"
47 53 ],
48 54 "metadata": {},
49 55 "output_type": "display_data"
50 56 },
51 57 {
52 58 "javascript": [
53 "$.getScript(\"../static/notebook/js/widgets/string.js\");"
59 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/bool.js\");"
54 60 ],
55 61 "metadata": {},
56 62 "output_type": "display_data"
57 63 },
58 64 {
59 65 "javascript": [
60 "$.getScript(\"../static/notebook/js/widgets/float.js\");"
66 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int.js\");"
61 67 ],
62 68 "metadata": {},
63 69 "output_type": "display_data"
64 70 },
65 71 {
66 72 "javascript": [
67 "$.getScript(\"../static/notebook/js/widgets/container.js\");"
73 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/selection.js\");"
68 74 ],
69 75 "metadata": {},
70 76 "output_type": "display_data"
71 77 },
72 78 {
73 79 "javascript": [
74 "$.getScript(\"../static/notebook/js/widgets/multicontainer.js\");"
80 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float.js\");"
75 81 ],
76 82 "metadata": {},
77 83 "output_type": "display_data"
78 84 },
79 85 {
80 86 "javascript": [
81 "$.getScript(\"../static/notebook/js/widgets/button.js\");"
87 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float_range.js\");"
82 88 ],
83 89 "metadata": {},
84 90 "output_type": "display_data"
85 91 },
86 92 {
87 93 "javascript": [
88 "$.getScript(\"../static/notebook/js/widgets/float_range.js\");"
94 "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/container.js\");"
89 95 ],
90 96 "metadata": {},
91 97 "output_type": "display_data"
@@ -221,26 +227,26 b''
221 227 "cell_type": "markdown",
222 228 "metadata": {},
223 229 "source": [
224 "The `ContainerWidget` also supports `start`, `center`, and `end` methods (parameterless) that adjust the alignment of the widgets on the axis that they are being rendered on. Below is an example of the different alignments."
230 "The `ContainerWidget` `pack_start`, `pack_center`, and `pack_end` methods (parameterless) adjust the alignment of the widgets on the axis that they are being rendered on. Below is an example of the different alignments."
225 231 ]
226 232 },
227 233 {
228 234 "cell_type": "code",
229 235 "collapsed": false,
230 236 "input": [
231 "container = make_container('HBox Start')\n",
237 "container = make_container('HBox Pack Start')\n",
232 238 "container.hbox()\n",
233 "container.start()\n",
239 "container.pack_start()\n",
234 240 "fill_container(container)\n",
235 241 " \n",
236 "container = make_container('HBox Center')\n",
242 "container = make_container('HBox Pack Center')\n",
237 243 "container.hbox()\n",
238 "container.center()\n",
244 "container.pack_center()\n",
239 245 "fill_container(container)\n",
240 246 " \n",
241 "container = make_container('HBox End')\n",
247 "container = make_container('HBox Pack End')\n",
242 248 "container.hbox()\n",
243 "container.end()\n",
249 "container.pack_end()\n",
244 250 "fill_container(container)"
245 251 ],
246 252 "language": "python",
@@ -252,6 +258,45 b''
252 258 "cell_type": "markdown",
253 259 "metadata": {},
254 260 "source": [
261 "The `ContainerWidget` `align_start`, `align_center`, and `align_end` methods (parameterless) adjust the alignment of the widgets on the axis perpindicular to the one that they are being rendered on. Below is an example of the different alignments."
262 ]
263 },
264 {
265 "cell_type": "code",
266 "collapsed": false,
267 "input": [
268 "def fill_container(container):\n",
269 " components = []\n",
270 " for i in range(3):\n",
271 " components.append(widgets.StringWidget(parent=container, default_view_name='LabelView', value=\"ABC\"[i]))\n",
272 " components[i].set_css(child_style)\n",
273 " components[i].set_css('height', str((i+1) * 50) + 'px')\n",
274 " display(components[i])\n",
275 "\n",
276 "container = make_container('HBox Align Start')\n",
277 "container.hbox()\n",
278 "container.align_start()\n",
279 "fill_container(container)\n",
280 " \n",
281 "container = make_container('HBox Align Center')\n",
282 "container.hbox()\n",
283 "container.align_center()\n",
284 "fill_container(container)\n",
285 " \n",
286 "container = make_container('HBox Align End')\n",
287 "container.hbox()\n",
288 "container.align_end()\n",
289 "fill_container(container)"
290 ],
291 "language": "python",
292 "metadata": {},
293 "outputs": [],
294 "prompt_number": 7
295 },
296 {
297 "cell_type": "markdown",
298 "metadata": {},
299 "source": [
255 300 "By default the widget area is a `vbox`; however, there are many uses for a `hbox`. The example below uses a `hbox` to display a set of vertical sliders, like an equalizer."
256 301 ]
257 302 },
@@ -268,7 +313,7 b''
268 313 "language": "python",
269 314 "metadata": {},
270 315 "outputs": [],
271 "prompt_number": 7
316 "prompt_number": 8
272 317 }
273 318 ],
274 319 "metadata": {}
General Comments 0
You need to be logged in to leave comments. Login now