File size: 4,219 Bytes
c0f084a
 
 
 
 
 
 
 
 
6de61f5
 
f612514
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
File: dropdown_candidates.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for Gradio app to filter dropdown candidates based on selected dropdown candidates.
License: MIT License
"""

# Importing necessary components for the Gradio app
from app.config import config_data
from app.utils import extract_profession_weights
from app.data_init import df_traits_priority_for_professions
from app.components import number_create_ui


def event_handler_dropdown_candidates(practical_subtasks, dropdown_candidates):
    if practical_subtasks.lower() == "professional groups":
        weights, interactive = extract_profession_weights(
            df_traits_priority_for_professions,
            dropdown_candidates,
        )

        return (
            number_create_ui(
                value=weights[0],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_OPE_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive,
                visible=True,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights[1],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_CON_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive,
                visible=True,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights[2],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_EXT_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive,
                visible=True,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights[3],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_AGR_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive,
                visible=True,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights[4],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_NNEU_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive,
                visible=True,
                render=True,
                elem_classes="number-container",
            ),
        )
    else:
        return (
            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),
        )