yetessam commited on
Commit
a6c95f0
·
verified ·
1 Parent(s): 5d1336e

Create CA_UI.py

Browse files
Files changed (1) hide show
  1. CA_UI.py +87 -0
CA_UI.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Custom CSS styles for sections
4
+ css = """
5
+ #header {
6
+ text-align: center;
7
+ font-size: 2em;
8
+ margin-bottom: 20px;
9
+ color: #333;
10
+ }
11
+ #user-guidance {
12
+ font-size: 1.1em;
13
+ color: #555;
14
+ margin-bottom: 20px;
15
+ }
16
+ #main {
17
+ padding: 20px;
18
+ background-color: #f7f7f7;
19
+ margin-bottom: 20px;
20
+ border-radius: 5px;
21
+ }
22
+ #examples {
23
+ font-size: 1.1em;
24
+ color: #333;
25
+ margin-bottom: 20px;
26
+ }
27
+ #footer {
28
+ text-align: center;
29
+ color: #888;
30
+ font-size: 0.9em;
31
+ }
32
+ """
33
+
34
+ # Function for Main content (takes user input and returns a response)
35
+ def process_input(user_input):
36
+ return f"You entered: {user_input}"
37
+
38
+ # Function to generate predefined examples
39
+ def get_example(example):
40
+ return f"You selected: {example}"
41
+
42
+ # Create the header section
43
+ def create_header():
44
+ with gr.Row():
45
+ gr.Markdown("<div id='header'>Welcome to My Gradio App</div>")
46
+
47
+ # Create the user guidance section
48
+ def create_user_guidance():
49
+ with gr.Row():
50
+ gr.Markdown("<div id='user-guidance'>Please enter some text below to get started. Select one of the examples to see the output instantly.</div>")
51
+
52
+ # Create the main content section
53
+ def create_main():
54
+ with gr.Row():
55
+ with gr.Column():
56
+ user_input = gr.Textbox(label="Your Input", placeholder="Enter something here...")
57
+ output = gr.Textbox(label="Output", interactive=False)
58
+ user_input.submit(process_input, inputs=user_input, outputs=output)
59
+ return output # Return the output component for further interactions in other sections
60
+
61
+ # Create the examples section
62
+ def create_examples(output):
63
+ with gr.Row():
64
+ gr.Markdown("<div id='examples'>Try one of these examples:</div>")
65
+ example_1 = gr.Button("Example 1: Hello World")
66
+ example_2 = gr.Button("Example 2: How are you?")
67
+ example_1.click(get_example, inputs="Example 1", outputs=output)
68
+ example_2.click(get_example, inputs="Example 2", outputs=output)
69
+
70
+ # Create the footer section
71
+ def create_footer():
72
+ with gr.Row():
73
+ gr.Markdown("<div id='footer'>© 2025 My Gradio App | All Rights Reserved</div>")
74
+
75
+ # Main function to bring all sections together
76
+ def ca_gui():
77
+ with gr.Blocks(css=css) as ca_gui:
78
+ create_header() # Create the header
79
+ create_user_guidance() # Create user guidance section
80
+ output = create_main() # Create the main section (returns the output component)
81
+ create_examples(output) # Create the examples section
82
+ create_footer() # Create the footer section
83
+
84
+ ca_gui.launch()
85
+
86
+ # Run the app
87
+ ca_gui()