File size: 1,586 Bytes
30b7eb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# This is a simple Gradio app that greets the user.
# The app includes a custom CSS to animate the front page information to expand and burst on the first click.

import gradio as gr

# Define a function that takes a name and returns a greeting.
def greet(name):
    return "Hello " + name + "!"

# Custom CSS to animate the front page information to expand and burst on the first click.
css = """
.front-page-info {
    transition: transform 0.5s, opacity 0.5s;
    opacity: 0;
    transform: scale(0);
}

.front-page-info.expanded {
    opacity: 1;
    transform: scale(1);
}
"""

# Create a Gradio interface that takes a textbox input, runs it through the greet function, and returns output to a textbox.
# The front page information is initially hidden and will expand and burst on the first click.
with gr.Blocks(css=css) as demo:
    front_page_info = gr.Markdown("Welcome to our amazing app! Click anywhere to start.", elem_classes="front-page-info")
    
    # Function to expand and burst the front page information on the first click.
    def expand_info():
        front_page_info.update(elem_classes="front-page-info expanded")
    
    # Attach the expand_info function to the first click event.
    front_page_info.click(expand_info, None, front_page_info)
    
    # Textbox and output for the greeting function.
    name = gr.Textbox(label="Name")
    output = gr.Textbox(label="Output Box")
    greet_btn = gr.Button("Greet")
    greet_btn.click(fn=greet, inputs=name, outputs=output)

# Launch the interface.
if __name__ == "__main__":
    demo.launch(show_error=True)