add padding between boxes
This commit is contained in:
parent
3e3c0af9d7
commit
786524a8eb
1 changed files with 38 additions and 39 deletions
|
|
@ -2,7 +2,7 @@
|
|||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
|
@ -23,12 +23,13 @@
|
|||
" w.Text(placeholder=\"E.g. Workshop without masks\", description=\"Simulation name:\",\n",
|
||||
" style={'description_width': '35%'}),\n",
|
||||
" w.Text(placeholder=\"E.g. 17/R-033\", description=\"Room number:\",\n",
|
||||
" style={'description_width': '35%'})))"
|
||||
" style={'description_width': '35%'})),\n",
|
||||
" layout=w.Layout(padding='0px 0px 50px 0px'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
|
@ -41,7 +42,8 @@
|
|||
"height_text = w.Text(placeholder=\"Room ceiling height (m²)\", description=\"Ceiling height\")\n",
|
||||
"\n",
|
||||
"room_dimensions_box = w.VBox(children=(volume_text, w.Label(value=\"------- OR -------\"),area_text, height_text),\n",
|
||||
" layout=w.Layout(align_items='center'))\n",
|
||||
" layout=w.Layout(padding='0px 0px 50px 0px'))\n",
|
||||
"\n",
|
||||
"def manage_room_text_fields(_):\n",
|
||||
" volume_text.disabled = bool(area_text.value) or bool(height_text.value)\n",
|
||||
" area_text.disabled = bool(volume_text.value)\n",
|
||||
|
|
@ -49,7 +51,7 @@
|
|||
"\n",
|
||||
"for text in [volume_text, area_text, height_text]:\n",
|
||||
" text.observe(manage_room_text_fields)\n",
|
||||
" text.style.description_width = \"50%\"\n",
|
||||
" text.style.description_width = \"auto\"\n",
|
||||
"\n",
|
||||
"volume_text.observe(manage_room_text_fields)\n",
|
||||
"area_text.observe(manage_room_text_fields)\n",
|
||||
|
|
@ -58,26 +60,13 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 145,
|
||||
"execution_count": 197,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": "VBox(children=(VBox(children=(Label(value='Ventilation type:'), HBox(children=(ToggleButton(value=False, descr…",
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "ac7739af0c0d456db756d4844a8f1b41"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ventilation_label = w.Label(\"Ventilation type:\")\n",
|
||||
"mechanical_button = w.ToggleButton(value=False, description='Mechanical', layout={'width': 'auto'})\n",
|
||||
|
|
@ -105,49 +94,59 @@
|
|||
" w.RadioButtons(options=('Always', '15 min / 2h'))\n",
|
||||
" ))\n",
|
||||
" ),\n",
|
||||
" layout=w.Layout(align_items='center', display='none'),\n",
|
||||
" layout=w.Layout(display='none'),\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"tab_bar = w.HBox(children=(mechanical_button, natural_button))\n",
|
||||
"ventilation_type_menu = w.VBox(children=(ventilation_label, tab_bar), layout=w.Layout(align_items='center', width='auto'))\n",
|
||||
"ventilation_menu = w.VBox(children=(ventilation_type_menu, mech_vent_box, nat_vent_box),\n",
|
||||
" layout=w.Layout(align_items='center'))\n",
|
||||
"ventilation_type_menu = w.VBox(children=(ventilation_label, tab_bar), layout=w.Layout(padding='0px 0px 20px 0px'))\n",
|
||||
"ventilation_box = w.VBox(children=(ventilation_type_menu, mech_vent_box, nat_vent_box),\n",
|
||||
" layout=w.Layout(padding='0px 0px 50px 0px'))\n",
|
||||
"\n",
|
||||
"def handle_natural_toggle(_):\n",
|
||||
" if natural_button.value:\n",
|
||||
" mechanical_button.value = False\n",
|
||||
" ventilation_menu.children[2].layout.display = 'block'\n",
|
||||
" ventilation_box.children[2].layout.display = 'block'\n",
|
||||
" else:\n",
|
||||
" ventilation_menu.children[2].layout.display = 'none'\n",
|
||||
" ventilation_box.children[2].layout.display = 'none'\n",
|
||||
"\n",
|
||||
"def handle_mechanical_toggle(_):\n",
|
||||
" if mechanical_button.value:\n",
|
||||
" natural_button.value = False\n",
|
||||
" ventilation_menu.children[1].layout.display = 'block'\n",
|
||||
" ventilation_box.children[1].layout.display = 'block'\n",
|
||||
" else:\n",
|
||||
" ventilation_menu.children[1].layout.display = 'none'\n",
|
||||
" ventilation_box.children[1].layout.display = 'none'\n",
|
||||
"\n",
|
||||
"natural_button.observe(handle_natural_toggle)\n",
|
||||
"mechanical_button.observe(handle_mechanical_toggle)\n",
|
||||
"\n",
|
||||
"ventilation_menu"
|
||||
"mechanical_button.observe(handle_mechanical_toggle)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"natural_button = w.ToggleButton(value=False, description='Mechanical ventilation', layout={'width': '100%'})\n"
|
||||
],
|
||||
"execution_count": 196,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": "VBox(children=(VBox(children=(HTML(value='<font size=\"+2\"><b>CARA</b> Covid Calculator</font>'), Text(value=''…",
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "06f418553b6d45448e35303e41b1ebb7"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"w.VBox(children=(intro_box, room_dimensions_box, ventilation_box))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue