add ventilation menu
This commit is contained in:
parent
5e3b5826cc
commit
3e3c0af9d7
1 changed files with 67 additions and 20 deletions
|
|
@ -58,7 +58,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 145,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
|
@ -67,40 +67,87 @@
|
|||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": "VBox(children=(VBox(children=(Label(value='Ventilation type:'), HBox(children=(ToggleButton(value=False, descr…",
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "a33e789cd87f4cff829c098073adcb4e",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"VBox(children=(ToggleButton(value=False, description='Mechanical ventilation', layout=Layout(width='100%')), T…"
|
||||
]
|
||||
"version_minor": 0,
|
||||
"model_id": "ac7739af0c0d456db756d4844a8f1b41"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"mechanical_button = w.ToggleButton(value=False, description='Mechanical ventilation', layout={'width': '100%'})\n",
|
||||
"acph_text = w.Text(description=\"Air changes per hour\", style={'description_width': 'aut'})\n",
|
||||
"asfr_text = w.Text(description=\"Air supply flow rate\", style={'description_width': '45%'})\n",
|
||||
"ventilation_label = w.Label(\"Ventilation type:\")\n",
|
||||
"mechanical_button = w.ToggleButton(value=False, description='Mechanical', layout={'width': 'auto'})\n",
|
||||
"natural_button = w.ToggleButton(value=False, description='Natural', layout={'width': 'auto'})\n",
|
||||
"\n",
|
||||
"def toggle_mechanical(b: w.Button):\n",
|
||||
" acph_text.disabled = not (mechanical_button.value or asfr_text.value)\n",
|
||||
" asfr_text.disabled = not (mechanical_button.value or acph_text.value)\n",
|
||||
"acph_text = w.Text(description=\"Air changes per hour\", style={'description_width': 'auto'})\n",
|
||||
"asfr_text = w.Text(description=\"Air supply flow rate\", style={'description_width': 'auto'})\n",
|
||||
"\n",
|
||||
"w.jsdlink((acph_text, 'value'), (asfr_text, 'disabled'))\n",
|
||||
"w.jsdlink((asfr_text, 'value'), (acph_text, 'disabled'))\n",
|
||||
"acph_text.disabled = True\n",
|
||||
"asfr_text.disabled = True\n",
|
||||
"\n",
|
||||
"mechanical_button.observe(toggle_mechanical)\n",
|
||||
"\n",
|
||||
"mech_vent_box = w.VBox(\n",
|
||||
" children=(mechanical_button, acph_text, w.Label(value=\"------- OR -------\"), asfr_text),\n",
|
||||
" layout=w.Layout(align_items='center')\n",
|
||||
")"
|
||||
" children=(acph_text, w.Label(value=\"------- OR -------\"), asfr_text),\n",
|
||||
" layout=w.Layout(display='none')\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"nat_vent_box = w.VBox(\n",
|
||||
" children=(\n",
|
||||
" w.Text(description='Number of windows:', style={'description_width': 'auto'}),\n",
|
||||
" w.Text(description='Height of window:', placeholder='meters', style={'description_width': 'auto'}),\n",
|
||||
" w.Text(description='Width of window:', placeholder='meters', style={'description_width': 'auto'}),\n",
|
||||
" w.Text(description='Opening distance:', placeholder='centimeters', style={'description_width': 'auto'}),\n",
|
||||
" w.HBox(children=(\n",
|
||||
" w.Label('Windows open'),\n",
|
||||
" w.RadioButtons(options=('Always', '15 min / 2h'))\n",
|
||||
" ))\n",
|
||||
" ),\n",
|
||||
" layout=w.Layout(align_items='center', 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",
|
||||
"\n",
|
||||
"def handle_natural_toggle(_):\n",
|
||||
" if natural_button.value:\n",
|
||||
" mechanical_button.value = False\n",
|
||||
" ventilation_menu.children[2].layout.display = 'block'\n",
|
||||
" else:\n",
|
||||
" ventilation_menu.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",
|
||||
" else:\n",
|
||||
" ventilation_menu.children[1].layout.display = 'none'\n",
|
||||
"\n",
|
||||
"natural_button.observe(handle_natural_toggle)\n",
|
||||
"mechanical_button.observe(handle_mechanical_toggle)\n",
|
||||
"\n",
|
||||
"ventilation_menu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"natural_button = w.ToggleButton(value=False, description='Mechanical ventilation', layout={'width': '100%'})\n"
|
||||
],
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue