File size: 1,054 Bytes
aa2aec1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
File: practical_task_sorted.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for the practical task sorted to the Gradio app.
License: MIT License
"""

import gradio as gr
from pathlib import Path

# Importing necessary components for the Gradio app
from app.components import video_create_ui


def event_handler_practical_task_sorted(
    files, practical_task_sorted, evt_data: gr.SelectData
):
    # print(
    #     f"{evt_data.value}, {evt_data.index}, {evt_data.target}, {evt_data.selected}, {evt_data._data}"
    # )
    # print(practical_task_sorted)

    # print(evt_data, evt_data.index[0], practical_task_sorted.iloc[evt_data.index[0]])

    person_id = int(practical_task_sorted.iloc[evt_data.index[0]]["Person ID"]) - 1

    if evt_data.index[0] == 0:
        label = "Best"
    else:
        label = ""
    label += " Person ID"

    return video_create_ui(
        value=files[person_id],
        file_name=Path(files[person_id]).name,
        label=f"{label} - " + str(person_id + 1),
        visible=True,
    )