Spaces:
Running
Running
File size: 3,759 Bytes
f51c1fd d0f716d f51c1fd c0f084a d0f716d f51c1fd d0f716d 0e30f40 aa2aec1 f51c1fd d0f716d f51c1fd 24ee878 42c4f80 f51c1fd 24ee878 f51c1fd 42c4f80 c0f084a d0f716d aa2aec1 1bf4da3 0e30f40 aa2aec1 0e30f40 c0f084a aa2aec1 b0f25b3 1bf4da3 aa2aec1 d0f716d f51c1fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
"""
File: clear_blocks.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for clearing Gradio app blocks and components.
License: MIT License
"""
import gradio as gr
# Importing necessary components for the Gradio app
from app.config import config_data
from app.description_steps import STEP_2
from app.practical_tasks import supported_practical_tasks
from app.components import (
html_message,
files_create_ui,
video_create_ui,
button,
dataframe,
radio_create_ui,
number_create_ui,
dropdown_create_ui,
)
def event_handler_clear_blocks():
first_practical_task = next(iter(supported_practical_tasks))
return (
html_message(config_data.InformationMessages_NOTI_VIDEOS, False),
files_create_ui(),
video_create_ui(),
button(
config_data.OtherMessages_CALCULATE_PT_SCORES,
False,
3,
"./images/calculate_pt_scores.ico",
True,
"calculate_oceanai",
),
button(
config_data.OtherMessages_CLEAR_APP,
False,
1,
"./images/clear.ico",
True,
"clear_oceanai",
),
dataframe(visible=False),
files_create_ui(
None,
"single",
[".csv"],
config_data.OtherMessages_EXPORT_PT_SCORES,
True,
False,
False,
"csv-container",
),
gr.HTML(value=STEP_2, visible=False),
gr.Column(visible=False),
radio_create_ui(
first_practical_task,
"Practical tasks",
list(map(str, supported_practical_tasks.keys())),
config_data.InformationMessages_PRACTICAL_TASKS_INFO,
True,
True,
),
radio_create_ui(
supported_practical_tasks[first_practical_task][0],
"Practical subtasks",
supported_practical_tasks[first_practical_task],
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
True,
True,
),
gr.JSON(
value={
str(task): supported_practical_tasks.get(task, [None])[0]
for task in supported_practical_tasks.keys()
},
visible=False,
render=True,
),
gr.Column(visible=False),
dropdown_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
dropdown_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
dropdown_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
gr.Row(visible=False),
gr.Column(visible=False),
dataframe(visible=False),
files_create_ui(
None,
"single",
[".csv"],
config_data.OtherMessages_EXPORT_PS,
True,
False,
False,
"csv-container",
),
gr.Accordion(visible=False),
gr.HTML(visible=False),
dataframe(visible=False),
video_create_ui(visible=False),
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
)
|