From 48aceedf1956233608ca6702ea1686f15b656731 Mon Sep 17 00:00:00 2001 From: SP9UNB Date: Wed, 12 Oct 2022 10:21:16 +0200 Subject: [PATCH] widget layout --- notebooks/hotair-box.ipynb | 113 +++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/notebooks/hotair-box.ipynb b/notebooks/hotair-box.ipynb index 4b39f8e..b9d0ebd 100644 --- a/notebooks/hotair-box.ipynb +++ b/notebooks/hotair-box.ipynb @@ -107,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 29, "id": "2f3b63fd-d5ea-40b6-a2f9-b31c84cfef36", "metadata": { "extensions": { @@ -129,49 +129,55 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "68aa2b284295445fbd69f50a344827cc", + "model_id": "b0fd2ea17df240dab9321a1d81ca8da9", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "interactive(children=(FloatSlider(value=2.0, description='Width [m]:', layout=Layout(width='500px'), max=5.0, …" + "VBox(children=(FloatSlider(value=2.0, description='Width [m]:', layout=Layout(width='500px'), max=5.0, min=0.1…" ] }, + "execution_count": 29, "metadata": {}, - "output_type": "display_data" + "output_type": "execute_result" } ], "source": [ "def f(width,height,depth,airTemp,hotAirTemp,coatDens):\n", - " print(\"\\n\")\n", - "# Volume\n", - " volume = width * height * depth\n", - " print( \"Volume: {:.2f} [m3]\".format(volume)) \n", - "# Area\n", - " area = 2 * (width * height + width * depth + height * depth)\n", - " print( \"Area: {:.2f} [m2]\".format(area)) \n", - "# Coating density (protective film for painting): 300g / 4x5m = 15g/m2 \n", - " coatingWeight = coatDens * area\n", - " print( \"Coating weight: {:.2f} [g]\".format(coatingWeight)) \n", - "# Lift per volume g/m3 \n", - "# airDens = dens_temp_func( airTemp )\n", - "# hotAirDens = dens_temp_func( hotAirTemp ) \n", - " airDens = airDensity( airTemp )\n", - " hotAirDens = airDensity( hotAirTemp ) \n", - " lift = airDens - hotAirDens\n", - " print( \"Lift: {:.2f} [g/m3]\".format(lift)) \n", - "# Total lift force lift * volume \n", - " totalLiftForce = lift * volume\n", - " print( \"Total lift force: {:.2f} [g]\".format(totalLiftForce)) \n", - "# Free lift force totalLiftForce - coatingWeight \n", - " freeLiftForce = totalLiftForce - coatingWeight\n", - " if freeLiftForce < 0:\n", - " color = 'red'\n", - " else:\n", - " color = None\n", - " print( \"Free lift force:\", colored(\"{:.2f} [g]\".format(freeLiftForce),color)) \n", - " print(\"\\n\")\n", + " \n", + " \n", + " out=widgets.Output(layout={'margin': '10px 10px 10px 10px'}) \n", + " with out: \n", + " print(\"\\n\")\n", + " # Volume\n", + " volume = width * height * depth\n", + " print( \"Volume: {:.2f} [m3]\".format(volume)) \n", + " # Area\n", + " area = 2 * (width * height + width * depth + height * depth)\n", + " print( \"Area: {:.2f} [m2]\".format(area)) \n", + " # Coating density (protective film for painting): 300g / 4x5m = 15g/m2 \n", + " coatingWeight = coatDens * area\n", + " print( \"Coating weight: {:.2f} [g]\".format(coatingWeight)) \n", + " # Lift per volume g/m3 \n", + " # airDens = dens_temp_func( airTemp )\n", + " # hotAirDens = dens_temp_func( hotAirTemp ) \n", + " airDens = airDensity( airTemp )\n", + " hotAirDens = airDensity( hotAirTemp ) \n", + " lift = airDens - hotAirDens\n", + " print( \"Lift: {:.2f} [g/m3]\".format(lift)) \n", + " # Total lift force lift * volume \n", + " totalLiftForce = lift * volume\n", + " print( \"Total lift force: {:.2f} [g]\".format(totalLiftForce)) \n", + " # Free lift force totalLiftForce - coatingWeight \n", + " freeLiftForce = totalLiftForce - coatingWeight\n", + " if freeLiftForce < 0:\n", + " color = 'red'\n", + " else:\n", + " color = None\n", + " print( \"Free lift force:\", colored(\"{:.2f} [g]\".format(freeLiftForce),color)) \n", + " print(\"\\n\")\n", "\n", + " \n", " box = Mesh(geometry=BoxBufferGeometry(\n", " width=width, \n", " height=height, \n", @@ -193,7 +199,10 @@ " clearOpacity=1.0,\n", " clearColor='#62a0ea',\n", " controls=[OrbitControls(controlling=c)])\n", - " return renderer\n", + " \n", + " display(widgets.HBox([renderer, out])) \n", + "# return renderer\n", + "\n", "\n", "#display(HTML('''