|
1 | 1 | {
|
2 | 2 | "cells": [
|
3 |
| - { |
4 |
| - "cell_type": "markdown", |
5 |
| - "metadata": {}, |
6 |
| - "source": [ |
7 |
| - "<!--NAVIGATION-->\n", |
8 |
| - "< [Contents](03.00-layout-and-styling-overview.ipynb) | [*OPTIONAL* - Widget label styling](03.02-OPTIONAL-widget-label-styling.ipynb) >" |
9 |
| - ] |
10 |
| - }, |
11 | 3 | {
|
12 | 4 | "cell_type": "markdown",
|
13 | 5 | "metadata": {},
|
|
23 | 15 | "cell_type": "markdown",
|
24 | 16 | "metadata": {},
|
25 | 17 | "source": [
|
26 |
| - "## The `layout` attribute.\n", |
| 18 | + "## The `layout` attribute\n", |
27 | 19 | "\n",
|
28 | 20 | "Jupyter interactive widgets have a `layout` attribute exposing a number of CSS properties that impact how widgets are laid out.\n",
|
29 | 21 | "\n",
|
30 |
| - "### Exposed CSS properties\n", |
| 22 | + "### CSS properties exposed with `layout` attribute\n", |
31 | 23 | "\n",
|
32 |
| - "<div class=\"alert alert-info\" style=\"margin: 20px\">\n", |
33 | 24 | "The following properties map to the values of the CSS properties of the same name (underscores being replaced with dashes), applied to the top DOM elements of the corresponding widget.\n",
|
34 |
| - "</div>\n", |
35 | 25 | "\n",
|
36 | 26 | "\n",
|
37 | 27 | "#### Sizes\n",
|
|
64 | 54 | "- `bottom`\n",
|
65 | 55 | "- `right`\n",
|
66 | 56 | "\n",
|
67 |
| - "#### Image/media\n", |
| 57 | + "#### Image / media\n", |
68 | 58 | "\n",
|
69 | 59 | "- `object_fit`\n",
|
70 | 60 | "- `object_position`\n",
|
|
189 | 179 | "metadata": {},
|
190 | 180 | "outputs": [],
|
191 | 181 | "source": [
|
192 |
| - "b2.style.button_color = 'yellow'" |
| 182 | + "b2.style.button_color = 'orange'" |
193 | 183 | ]
|
194 | 184 | },
|
195 | 185 | {
|
|
239 | 229 | "outputs": [],
|
240 | 230 | "source": [
|
241 | 231 | "from ipywidgets import IntSlider\n",
|
242 |
| - "s1 = IntSlider(description='Blue handle')\n", |
243 |
| - "s1.style.handle_color = 'lightblue'\n", |
| 232 | + "s1 = IntSlider(description='Red handle')\n", |
| 233 | + "s1.style.handle_color = 'red'\n", |
244 | 234 | "s1"
|
245 | 235 | ]
|
246 | 236 | },
|
|
349 | 339 | " \"\"\"Displays multiple widgets horizontally using the flexible box model.\"\"\"\n",
|
350 | 340 | " box = Box(*pargs, **kwargs)\n",
|
351 | 341 | " box.layout.display = 'flex'\n",
|
| 342 | + " box.layout.flex_flow = 'row'\n", |
352 | 343 | " box.layout.align_items = 'stretch'\n",
|
353 | 344 | " return box\n",
|
354 | 345 | "```\n",
|
|
380 | 371 | "source": [
|
381 | 372 | "from ipywidgets import Layout, Button, Box\n",
|
382 | 373 | "\n",
|
383 |
| - "items_layout = Layout(width='auto') # override the default width of the button to 'auto' to let the button grow\n", |
| 374 | + "items_layout = Layout(width='auto') # override the default width of the button to 'auto' to let the button grow\n", |
384 | 375 | "\n",
|
385 | 376 | "box_layout = Layout(display='flex',\n",
|
386 |
| - " flex_flow='column', \n", |
| 377 | + " flex_flow='column',\n", |
387 | 378 | " align_items='stretch', \n",
|
388 | 379 | " border='solid',\n",
|
389 | 380 | " width='50%')\n",
|
|
410 | 401 | "from ipywidgets import Layout, Button, HBox\n",
|
411 | 402 | "\n",
|
412 | 403 | "items = [\n",
|
413 |
| - " Button(description='weight=1; 0%', layout=Layout(flex='1 1 0%', width='auto'), button_style='danger'),\n", |
414 |
| - " Button(description='weight=3; 0%', layout=Layout(flex='3 1 0%', width='auto'), button_style='danger'),\n", |
415 |
| - " Button(description='weight=1; 0%', layout=Layout(flex='1 1 0%', width='auto'), button_style='danger'),\n", |
| 404 | + " Button(description='weight=1', layout=Layout(flex='1', width='auto'), button_style='danger'),\n", |
| 405 | + " Button(description='weight=3', layout=Layout(flex='3', width='auto'), button_style='danger'),\n", |
| 406 | + " Button(description='weight=1', layout=Layout(flex='1', width='auto'), button_style='danger'),\n", |
416 | 407 | "]\n",
|
417 | 408 | "box_layout = Layout(align_items='stretch', width='70%')\n",
|
418 | 409 | "HBox(children=items, layout=box_layout)"
|
|
737 | 728 | "source": [
|
738 | 729 | "from ipywidgets import Layout, Button, Box\n",
|
739 | 730 | "\n",
|
740 |
| - "items_layout = Layout(width='auto') # override the default width of the button to 'auto' to let the button grow\n", |
| 731 | + "items_layout = Layout(width='auto') # override the default width of the button to 'auto' to let the button grow\n", |
741 | 732 | "\n",
|
742 | 733 | "box_layout = Layout(display='flex',\n",
|
743 | 734 | " flex_flow='column', \n",
|
|
877 | 868 | "metadata": {},
|
878 | 869 | "outputs": [],
|
879 | 870 | "source": [
|
880 |
| - "# Utils widgets\n", |
881 | 871 | "from ipywidgets import Button, Layout, jslink, IntText, IntSlider\n",
|
882 | 872 | "\n",
|
883 | 873 | "def create_expanded_button(description, button_style):\n",
|
|
1430 | 1420 | " scatt = bq.Scatter(x=data[:, j], y=data[:, i], scales={'x': sc_x, 'y': sc_y})\n",
|
1431 | 1421 | "\n",
|
1432 | 1422 | " gs[i, j] = bq.Figure(marks=[scatt], layout=Layout(width='auto', height='auto'),\n",
|
1433 |
| - " fig_margin=dict(top=5, bottom=5, left=5, right=5), background_style={'fill':'#f5f5ff'})\n", |
| 1423 | + " fig_margin=dict(top=5, bottom=5, left=5, right=5), background_style={'fill':'#e5e5ff'})\n", |
1434 | 1424 | " else:\n",
|
1435 | 1425 | " sc_x = scales_x[j]\n",
|
1436 | 1426 | " sc_y = bq.LinearScale()\n",
|
1437 | 1427 | " \n",
|
1438 | 1428 | " hist = bq.Hist(sample=data[:,i], scales={'sample': sc_x, 'count': sc_y})\n",
|
1439 | 1429 | " \n",
|
1440 | 1430 | " gs[i, j] = bq.Figure(marks=[hist], layout=Layout(width='auto', height='auto'),\n",
|
1441 |
| - " fig_margin=dict(top=5, bottom=5, left=5, right=5), background_style={'fill':'#f5f5ff'})\n", |
| 1431 | + " fig_margin=dict(top=5, bottom=5, left=5, right=5), background_style={'fill':'#e5e5ff'})\n", |
1442 | 1432 | "gs"
|
1443 | 1433 | ]
|
1444 | 1434 | },
|
|
1477 | 1467 | " layout=Layout(\n",
|
1478 | 1468 | " width='50%',\n",
|
1479 | 1469 | " grid_template_columns='100px 50px 100px',\n",
|
1480 |
| - " grid_template_rows='80px auto 80px', \n", |
| 1470 | + " grid_template_rows='80px auto 80px',\n", |
1481 | 1471 | " grid_gap='5px 10px')\n",
|
1482 | 1472 | " )"
|
1483 | 1473 | ]
|
|
1534 | 1524 | " style=ButtonStyle(button_color='lightblue'))\n",
|
1535 | 1525 | "main = Button(description='Main',\n",
|
1536 | 1526 | " layout=Layout(width='auto', height='auto', grid_area='main'),\n",
|
1537 |
| - " style=ButtonStyle(button_color='moccasin'))\n", |
| 1527 | + " style=ButtonStyle(button_color='lightgray'))\n", |
1538 | 1528 | "sidebar = Button(description='Sidebar',\n",
|
1539 | 1529 | " layout=Layout(width='auto', height='auto', grid_area='sidebar'),\n",
|
1540 | 1530 | " style=ButtonStyle(button_color='salmon'))\n",
|
1541 | 1531 | "footer = Button(description='Footer',\n",
|
1542 | 1532 | " layout=Layout(width='auto', height='auto', grid_area='footer'),\n",
|
1543 |
| - " style=ButtonStyle(button_color='olive'))\n", |
| 1533 | + " style=ButtonStyle(button_color='orange'))\n", |
1544 | 1534 | "\n",
|
1545 | 1535 | "GridBox(children=[header, main, sidebar, footer],\n",
|
1546 | 1536 | " layout=Layout(\n",
|
|
1577 | 1567 | "metadata": {},
|
1578 | 1568 | "source": [
|
1579 | 1569 | "<!--NAVIGATION-->\n",
|
1580 |
| - "< [Layout and Styling of Jupyter widgets](03.00-layout-and-styling-overview.ipynb) | [*OPTIONAL* - Widget label styling](03.02-OPTIONAL-widget-label-styling.ipynb) >" |
| 1570 | + "< [Contents](03.00-layout-and-styling-overview.ipynb) | [*OPTIONAL* - Widget Label Styling](03.02-OPTIONAL-widget-label-styling.ipynb) >" |
1581 | 1571 | ]
|
1582 | 1572 | }
|
1583 | 1573 | ],
|
|
0 commit comments