File size: 1,392 Bytes
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
"""
File: event_handlers.py
Author: Dmitry Ryumin
Description: File containing functions for configuring event handlers for Gradio components.
License: MIT License
"""

import gradio as gr

# Importing necessary components for the Gradio app
from app.event_handlers.files import (
    event_handler_files,
    event_handler_files_select,
)
from app.event_handlers.clear_blocks import event_handler_clear_blocks
from app.event_handlers.calculate_pt_scores_blocks import (
    event_handler_calculate_pt_scores_blocks,
)


def setup_app_event_handlers(
    notifications, files, video, calculate_pt_scores, clear_app, pt_scores
):
    # Events
    files.change(
        event_handler_files,
        [files],
        [notifications, video, calculate_pt_scores, clear_app],
        queue=True,
    )
    files.select(
        event_handler_files_select,
        [files],
        [video],
        queue=True,
    )
    gr.on(
        triggers=[calculate_pt_scores.click],
        fn=event_handler_calculate_pt_scores_blocks,
        inputs=[files],
        outputs=[notifications, pt_scores],
        queue=True,
    )
    clear_app.click(
        fn=event_handler_clear_blocks,
        inputs=[],
        outputs=[
            notifications,
            files,
            video,
            calculate_pt_scores,
            clear_app,
            pt_scores,
        ],
        queue=True,
    )