From bdf9614f6a5e895a9a3c7f6e65201123aba21716 Mon Sep 17 00:00:00 2001 From: markus Date: Thu, 22 Oct 2020 10:40:40 +0200 Subject: [PATCH] fix box for providing room dimensions --- app/covid-calculator.ipynb | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/app/covid-calculator.ipynb b/app/covid-calculator.ipynb index 7ebab4c9..52ad5c35 100644 --- a/app/covid-calculator.ipynb +++ b/app/covid-calculator.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 49, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 5, "metadata": { "pycharm": { "name": "#%%\n" @@ -24,7 +24,7 @@ "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, - "model_id": "61c53e6d9b58415097dce93a3a0e96c7" + "model_id": "b6dfcf9858f24a84bf9bac4918b328a5" } }, "metadata": {}, @@ -41,36 +41,28 @@ }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 20, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [ - { - "data": { - "text/plain": "VBox(children=(Text(value='', placeholder='Room volume (m³)'), Label(value='OR'), Text(value='', placeholder='…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "bea9900594a14d078ab222436b922b5e" - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "volume_text = w.Text(placeholder=\"Room volume (m³)\")\n", "area_text = w.Text(placeholder=\"Room floor area (m²)\")\n", "height_text = w.Text(placeholder=\"Room ceiling height (m²)\")\n", "\n", - "w.jslink((volume_text, 'value'), (area_text, 'disabled'))\n", - "w.jslink((volume_text, 'value'), (height_text, 'disabled'))\n", - "w.jslink((area_text, 'value'), (volume_text, 'disabled'))\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", + " 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", - "w.VBox(children=(volume_text, w.Label(value=\"OR\"),area_text, height_text), layout=w.Layout(align_items='center'))" + "volume_text.observe(manage_text_fields)\n", + "area_text.observe(manage_text_fields)\n", + "height_text.observe(manage_text_fields)" ] } ],