feat: subsection split with radio buttons
Browse files- app/assets/logos/destruction.png +0 -0
- app/assets/logos/indirect.png +0 -0
- app/assets/logos/natural.png +0 -0
- app/assets/logos/van.png +0 -0
- app/causes.py +64 -0
- app/dead.py +2 -3
- app/main.py +15 -4
- app/top_section.py +0 -34
- app/wounded.py +10 -5
app/assets/logos/destruction.png
CHANGED
![]() |
![]() |
app/assets/logos/indirect.png
CHANGED
![]() |
![]() |
app/assets/logos/natural.png
CHANGED
![]() |
![]() |
app/assets/logos/van.png
CHANGED
![]() |
![]() |
app/causes.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
PATH = os.getcwd()
|
5 |
+
CAUSE_COL_WIDTH = "50px"
|
6 |
+
|
7 |
+
def set_visible(choice):
|
8 |
+
if choice=="Yes":
|
9 |
+
visible = True
|
10 |
+
else:
|
11 |
+
visible=False
|
12 |
+
return visible
|
13 |
+
|
14 |
+
def show_causes(choice):
|
15 |
+
visible = set_visible(choice)
|
16 |
+
button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes(visible)
|
17 |
+
return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
18 |
+
|
19 |
+
def create_causes(visible):
|
20 |
+
button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_causes_buttons(visible)
|
21 |
+
dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes_dropdown(visible)
|
22 |
+
return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
23 |
+
|
24 |
+
|
25 |
+
def create_causes_buttons(visible):
|
26 |
+
print(visible)
|
27 |
+
with gr.Row() as image_row:
|
28 |
+
with gr.Column(scale=1, min_width=CAUSE_COL_WIDTH):
|
29 |
+
button_collision = gr.Button("Collision with a means of transport",
|
30 |
+
visible=visible,
|
31 |
+
icon=PATH + '/assets/logos/van.png',
|
32 |
+
elem_id="buttons-conditions")
|
33 |
+
|
34 |
+
with gr.Column(scale=1, min_width=CAUSE_COL_WIDTH):
|
35 |
+
button_deliberate_destruction = gr.Button("Destruction / Deliberatly removed",
|
36 |
+
icon=PATH + '/assets/logos/destruction.png',
|
37 |
+
visible=visible,
|
38 |
+
elem_id="buttons-conditions")
|
39 |
+
|
40 |
+
with gr.Column(scale=1, min_width=CAUSE_COL_WIDTH):
|
41 |
+
button_indirect_destruction = gr.Button("Indirect destruction",
|
42 |
+
icon=PATH + '/assets/logos/indirect.png',
|
43 |
+
visible=visible,
|
44 |
+
elem_id="buttons-conditions")
|
45 |
+
|
46 |
+
with gr.Column(scale=1, min_width=CAUSE_COL_WIDTH):
|
47 |
+
button_natural_cause = gr.Button("Natural cause",
|
48 |
+
icon=PATH + '/assets/logos/natural.png',
|
49 |
+
visible=visible,
|
50 |
+
elem_id="buttons-conditions")
|
51 |
+
return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause
|
52 |
+
|
53 |
+
def create_causes_dropdown(visible):
|
54 |
+
with gr.Row() as dropdown_row:
|
55 |
+
dropdown = gr.Dropdown(choices=[],
|
56 |
+
label="Choices will appear here...",
|
57 |
+
visible=visible, interactive=False, elem_id="dropdown-conditions")
|
58 |
+
openfield_level2 = gr.Textbox(visible=False, elem_id="dropdown-conditions")
|
59 |
+
dropdown_level2 = gr.Dropdown(choices=[], visible=False, elem_id="dropdown-conditions")
|
60 |
+
dropdown_extra_level2 = gr.Dropdown(choices=[], visible=False, elem_id="dropdown-conditions")
|
61 |
+
return dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
62 |
+
|
63 |
+
|
64 |
+
|
app/dead.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
from followup_events import create_followup_section
|
4 |
|
5 |
|
@@ -8,8 +8,7 @@ def show_section_dead(visible):
|
|
8 |
gr.Markdown("# Dead Animal")
|
9 |
gr.Markdown("## Please describe the cause of death", label="description")
|
10 |
|
11 |
-
|
12 |
-
dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_dropdown(visible)
|
13 |
|
14 |
create_followup_section()
|
15 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from causes import create_causes
|
3 |
from followup_events import create_followup_section
|
4 |
|
5 |
|
|
|
8 |
gr.Markdown("# Dead Animal")
|
9 |
gr.Markdown("## Please describe the cause of death", label="description")
|
10 |
|
11 |
+
button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes(visible)
|
|
|
12 |
|
13 |
create_followup_section()
|
14 |
|
app/main.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
from functools import partial
|
3 |
from dead import show_section_dead
|
4 |
from wounded import show_section_wounded
|
|
|
5 |
from dropdowns import *
|
6 |
from maps import get_location
|
7 |
from style import *
|
@@ -52,7 +53,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
52 |
# ---------------------------------------------------------
|
53 |
# Initiate sections
|
54 |
section_dead, button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead = show_section_dead(False)
|
55 |
-
section_wounded, button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded= show_section_wounded(False)
|
56 |
|
57 |
# ---------------------------------------------------------
|
58 |
# Dead Button Logic
|
@@ -63,6 +64,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
63 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
|
64 |
])
|
65 |
butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=[section_wounded,
|
|
|
66 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
67 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded
|
68 |
])
|
@@ -71,9 +73,10 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
71 |
partial_show_section_wounded = partial(show_section_wounded, True)
|
72 |
partial_hide_section_dead = partial(show_section_dead, False)
|
73 |
butt_wounded.click(partial_show_section_wounded, inputs=None, outputs=[section_wounded,
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
77 |
butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,
|
78 |
button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
|
79 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
|
@@ -88,6 +91,14 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
88 |
|
89 |
dropdown_dead.select(on_select, None, [dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead])
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
# ---------------------------------------------------------
|
92 |
# Dropdowns Wounded
|
93 |
button_collision_wounded.click(dropdown_collision,
|
|
|
2 |
from functools import partial
|
3 |
from dead import show_section_dead
|
4 |
from wounded import show_section_wounded
|
5 |
+
from causes import show_causes
|
6 |
from dropdowns import *
|
7 |
from maps import get_location
|
8 |
from style import *
|
|
|
53 |
# ---------------------------------------------------------
|
54 |
# Initiate sections
|
55 |
section_dead, button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead = show_section_dead(False)
|
56 |
+
section_wounded, radio_cause_wounded, radio_behaviour_wounded, radio_physical_wounded, button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded= show_section_wounded(False)
|
57 |
|
58 |
# ---------------------------------------------------------
|
59 |
# Dead Button Logic
|
|
|
64 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
|
65 |
])
|
66 |
butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=[section_wounded,
|
67 |
+
radio_cause_wounded, radio_behaviour_wounded, radio_physical_wounded,
|
68 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
69 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded
|
70 |
])
|
|
|
73 |
partial_show_section_wounded = partial(show_section_wounded, True)
|
74 |
partial_hide_section_dead = partial(show_section_dead, False)
|
75 |
butt_wounded.click(partial_show_section_wounded, inputs=None, outputs=[section_wounded,
|
76 |
+
radio_cause_wounded, radio_behaviour_wounded, radio_physical_wounded,
|
77 |
+
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
78 |
+
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded
|
79 |
+
])
|
80 |
butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,
|
81 |
button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
|
82 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
|
|
|
91 |
|
92 |
dropdown_dead.select(on_select, None, [dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead])
|
93 |
|
94 |
+
# ---------------------------------------------------------
|
95 |
+
# Radio Wounded
|
96 |
+
radio_cause_wounded.change(fn=show_causes,
|
97 |
+
inputs=[radio_cause_wounded],
|
98 |
+
outputs=[button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
99 |
+
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded]
|
100 |
+
)
|
101 |
+
|
102 |
# ---------------------------------------------------------
|
103 |
# Dropdowns Wounded
|
104 |
button_collision_wounded.click(dropdown_collision,
|
app/top_section.py
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import os
|
3 |
-
|
4 |
-
PATH = os.getcwd()
|
5 |
-
|
6 |
-
def create_top_section(visible):
|
7 |
-
with gr.Row() as image_row:
|
8 |
-
with gr.Column(scale=1, min_width="50px"):
|
9 |
-
img1 = gr.Image(value=PATH + '/assets/logos/van.png', show_download_button=False, show_label=False, height="150px")
|
10 |
-
button_collision = gr.Button("Collision with a means of transport", visible=visible, elem_id="buttons-conditions")
|
11 |
-
|
12 |
-
with gr.Column(scale=1, min_width="50px"):
|
13 |
-
img2 = gr.Image(value=PATH + '/assets/logos/destruction.png', show_download_button=False, show_label=False, height="150px")
|
14 |
-
button_deliberate_destruction = gr.Button("Destruction / Deliberatly removed", visible=visible, elem_id="buttons-conditions")
|
15 |
-
|
16 |
-
with gr.Column(scale=1, min_width="50px"):
|
17 |
-
img3 = gr.Image(value=PATH + '/assets/logos/indirect.png', show_download_button=False, show_label=False, height="150px")
|
18 |
-
button_indirect_destruction = gr.Button("Indirect destruction", visible=visible, elem_id="buttons-conditions")
|
19 |
-
|
20 |
-
with gr.Column(scale=1, min_width="50px"):
|
21 |
-
img4 = gr.Image(value=PATH + '/assets/logos/natural.png', show_download_button=False, show_label=False, height="150px")
|
22 |
-
button_natural_cause = gr.Button("Natural cause", visible=visible, elem_id="buttons-conditions")
|
23 |
-
return image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause
|
24 |
-
|
25 |
-
def create_dropdown(visible):
|
26 |
-
with gr.Row() as dropdown_row:
|
27 |
-
dropdown = gr.Dropdown(choices=[], interactive=False, visible=visible, elem_id="dropdown-conditions")
|
28 |
-
openfield_level2 = gr.Textbox(visible=False, elem_id="dropdown-conditions")
|
29 |
-
dropdown_level2 = gr.Dropdown(choices=[], visible=False, elem_id="dropdown-conditions")
|
30 |
-
dropdown_extra_level2 = gr.Dropdown(choices=[], visible=False, elem_id="dropdown-conditions")
|
31 |
-
return dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/wounded.py
CHANGED
@@ -1,16 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
from followup_events import create_followup_section
|
4 |
|
5 |
def show_section_wounded(visible):
|
6 |
with gr.Column(visible=visible, elem_id="wounded") as wounded_section:
|
7 |
gr.Markdown("# Wounded Animal")
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
|
|
|
|
13 |
create_followup_section()
|
14 |
|
15 |
# Change variables and names
|
16 |
-
return wounded_section, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
|
|
1 |
import gradio as gr
|
2 |
+
from causes import create_causes
|
3 |
from followup_events import create_followup_section
|
4 |
|
5 |
def show_section_wounded(visible):
|
6 |
with gr.Column(visible=visible, elem_id="wounded") as wounded_section:
|
7 |
gr.Markdown("# Wounded Animal")
|
8 |
+
|
9 |
+
gr.Markdown("## Do you know what conditions caused this?", label="description")
|
10 |
+
radio_cause = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
|
11 |
+
button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes(visible=False)
|
12 |
|
13 |
+
gr.Markdown("## Is the bird displaying behavioural changes?" , label="description")
|
14 |
+
radio_behaviour = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
|
15 |
|
16 |
+
gr.Markdown("## Are there physical changes on the bird?" , label="description")
|
17 |
+
radio_physical = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
|
18 |
create_followup_section()
|
19 |
|
20 |
# Change variables and names
|
21 |
+
return wounded_section, radio_cause, radio_behaviour, radio_physical, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|