add elements for setting time, date and breaks
This commit is contained in:
parent
786524a8eb
commit
2a7fa5b106
1 changed files with 89 additions and 8 deletions
|
|
@ -2,7 +2,7 @@
|
|||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 197,
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
|
@ -124,7 +124,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 196,
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
|
@ -133,11 +133,11 @@
|
|||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": "VBox(children=(VBox(children=(HTML(value='<font size=\"+2\"><b>CARA</b> Covid Calculator</font>'), Text(value=''…",
|
||||
"text/plain": "VBox(children=(ToggleButton(value=False, description='Lunch break'), HBox(children=(VBox(children=(Label(value…",
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "06f418553b6d45448e35303e41b1ebb7"
|
||||
"model_id": "5998e5c52baa48b4af05c6c65acef726"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
|
|
@ -145,7 +145,88 @@
|
|||
}
|
||||
],
|
||||
"source": [
|
||||
"w.VBox(children=(intro_box, room_dimensions_box, ventilation_box))"
|
||||
"event_data_label = w.Label(\"Event data:\")\n",
|
||||
"attendees_label = w.Label(\"Attendees:\")\n",
|
||||
"total_people_text = w.Text(description=\"Total number of people:\", style={'description_width': 'auto'})\n",
|
||||
"infected_people_text = w.Text(description=\"Number of infected people:\", style={'description_width': 'auto'})\n",
|
||||
"activity_dropdown = w.Dropdown(description=\"Activity type:\", options=[\"Training\", \"Workshop\", \"Office\"], value=None)\n",
|
||||
"start_hour = w.Dropdown(options=[\"HH\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(24)], value=\"HH\")\n",
|
||||
"start_minute = w.Dropdown(options=[\"MM\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(60)], value=\"MM\")\n",
|
||||
"finish_hour = w.Dropdown(options=[\"HH\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(24)], value=\"HH\")\n",
|
||||
"finish_minute = w.Dropdown(options=[\"MM\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(60)], value=\"MM\")\n",
|
||||
"start_box = w.VBox(children=(w.Label(\"Start:\"),\n",
|
||||
" w.HBox(children=(start_hour, start_minute))),\n",
|
||||
" layout=w.Layout(padding=\"0px 20px 0px 0px\"))\n",
|
||||
"finish_box = w.VBox(children=(w.Label(\"Finish:\"),\n",
|
||||
" w.HBox(children=(finish_hour, finish_minute))))\n",
|
||||
"event_time_box = w.HBox(children=(start_box, finish_box))\n",
|
||||
"\n",
|
||||
"event_intro_box = w.VBox(children=(\n",
|
||||
" event_data_label,\n",
|
||||
" attendees_label,\n",
|
||||
" total_people_text,\n",
|
||||
" infected_people_text,\n",
|
||||
" activity_dropdown,\n",
|
||||
" event_time_box\n",
|
||||
"))\n",
|
||||
"\n",
|
||||
"months = (\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n",
|
||||
" \"July\", \"August\", \"September\", \"October\", \"November\", \"December\")\n",
|
||||
"\n",
|
||||
"single_button = w.ToggleButton(value=False, description='Single event', layout={'width': 'auto'})\n",
|
||||
"recurrent_button = w.ToggleButton(value=False, description='Recurrent usage', layout={'width': 'auto'})\n",
|
||||
"single_recurrent_selection_bar = w.HBox(children=(single_button, recurrent_button))\n",
|
||||
"month_dropdown = w.Dropdown(options=months, value=None, description=\"Month:\", layout=w.Layout(padding=\"0px 20px 0px 0px\"))\n",
|
||||
"day_dropdown = w.Dropdown(options=[i for i in range(1, 32)], value=None, description=\"Day:\")\n",
|
||||
"date_selector = w.HBox(children=(month_dropdown, day_dropdown), layout=w.Layout(display='none'))\n",
|
||||
"months_bar = w.HBox(children=[w.ToggleButton(value=False, description=month[0]) for month in months],\n",
|
||||
" layout = w.Layout(display='none'))\n",
|
||||
"\n",
|
||||
"def handle_single_click(_):\n",
|
||||
" if single_button.value:\n",
|
||||
" date_selector.layout.display = 'contents'\n",
|
||||
" recurrent_button.value = False\n",
|
||||
" else:\n",
|
||||
" date_selector.layout.display = 'none'\n",
|
||||
"\n",
|
||||
"def handle_recurrent_click(_):\n",
|
||||
" if recurrent_button.value:\n",
|
||||
" months_bar.layout.display = 'contents'\n",
|
||||
" single_button.value = False\n",
|
||||
" else:\n",
|
||||
" months_bar.layout.display = 'none'\n",
|
||||
"\n",
|
||||
"single_button.observe(handle_single_click)\n",
|
||||
"recurrent_button.observe(handle_recurrent_click)\n",
|
||||
"\n",
|
||||
"date_box = w.VBox(children=(w.HBox(children=(single_button, recurrent_button)),\n",
|
||||
" w.HBox(children=(date_selector, months_bar))))\n",
|
||||
"\n",
|
||||
"lunch_start_hour = w.Dropdown(options=[\"HH\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(24)],\n",
|
||||
" value=\"HH\", disabled=True)\n",
|
||||
"lunch_start_minute = w.Dropdown(options=[\"MM\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(60)],\n",
|
||||
" value=\"MM\", disabled=True)\n",
|
||||
"lunch_finish_hour = w.Dropdown(options=[\"HH\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(24)],\n",
|
||||
" value=\"HH\", disabled=True)\n",
|
||||
"lunch_finish_minute = w.Dropdown(options=[\"MM\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(60)],\n",
|
||||
" value=\"MM\", disabled=True)\n",
|
||||
"lunch_start_box = w.VBox(children=(w.Label(\"Start:\"),\n",
|
||||
" w.HBox(children=(lunch_start_hour, lunch_start_minute))),\n",
|
||||
" layout=w.Layout(padding=\"0px 20px 0px 0px\"))\n",
|
||||
"lunch_finish_box = w.VBox(children=(w.Label(\"Finish:\"),\n",
|
||||
" w.HBox(children=(lunch_finish_minute, lunch_finish_minute))))\n",
|
||||
"lunch_time_box = w.HBox(children=(lunch_start_box, lunch_finish_box))\n",
|
||||
"\n",
|
||||
"lunch_button = w.ToggleButton(value=False, description=\"Lunch break\")\n",
|
||||
"\n",
|
||||
"def handle_lunch(_):\n",
|
||||
" for dropdown in (lunch_start_hour, lunch_start_minute, lunch_finish_hour, lunch_finish_minute):\n",
|
||||
" dropdown.disabled = not lunch_button.value\n",
|
||||
"\n",
|
||||
"lunch_button.observe(handle_lunch)\n",
|
||||
"\n",
|
||||
"break_box = w.VBox(children=(lunch_button, lunch_time_box))\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue