diff --git a/app/covid-calculator.ipynb b/app/covid-calculator.ipynb index 15f4517d..c6ede9cf 100644 --- a/app/covid-calculator.ipynb +++ b/app/covid-calculator.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 4, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -11,58 +11,30 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 15, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [ - { - "data": { - "text/plain": "VBox(children=(HTML(value='CARA Covid Calculator'), Text(value='', description='…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "cb4016cbd61a455780fd5b7d9b8585db" - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ - "intro = w.VBox(children=(w.HTML(value='CARA Covid Calculator'),\n", + "intro_box = w.VBox(children=(w.HTML(value='CARA Covid Calculator'),\n", " 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%'})))\n", - "\n", - "intro" + " style={'description_width': '35%'})))" ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 16, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [ - { - "data": { - "text/plain": "VBox(children=(Text(value='', description='Room volume', placeholder='Room volume (m³)', style=DescriptionStyl…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "152f11e8cd014cd5847392b559a4424b" - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "volume_text = w.Text(placeholder=\"Room volume (m³)\", description=\"Room volume\")\n", "area_text = w.Text(placeholder=\"Room floor area (m²)\", description=\"Floor area\")\n", @@ -70,20 +42,64 @@ "\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", - "def manage_text_fields(b):\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", " height_text.disabled = bool(volume_text.value)\n", "\n", "for text in [volume_text, area_text, height_text]:\n", - " text.observe(manage_text_fields)\n", + " text.observe(manage_room_text_fields)\n", " text.style.description_width = \"50%\"\n", "\n", - "volume_text.observe(manage_text_fields)\n", - "area_text.observe(manage_text_fields)\n", - "height_text.observe(manage_text_fields)\n", + "volume_text.observe(manage_room_text_fields)\n", + "area_text.observe(manage_room_text_fields)\n", + "height_text.observe(manage_room_text_fields)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "data": { + "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…" + ] + }, + "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", "\n", - "room_dimensions_box" + "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", + "\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", + ")" ] } ],