Update app.py
Browse files
app.py
CHANGED
@@ -1,112 +1,34 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
# Fungsi untuk
|
4 |
-
def
|
5 |
-
return "
|
6 |
|
7 |
-
|
8 |
-
|
|
|
9 |
|
10 |
-
#
|
11 |
-
custom_css = """
|
12 |
-
@import url('https://fonts.googleapis.com/css2?family=Itim&display=swap');
|
13 |
-
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;700&display=swap');
|
14 |
-
|
15 |
-
body {
|
16 |
-
background: linear-gradient(to bottom, #FFA500, #1E90FF); /* Gradient background */
|
17 |
-
color: #ffffff !important; /* White text */
|
18 |
-
margin: 0;
|
19 |
-
padding: 0;
|
20 |
-
overflow: hidden; /* Prevent extra scrollbars outside the container */
|
21 |
-
}
|
22 |
-
|
23 |
-
.gradio-container {
|
24 |
-
max-height: 90vh; /* Batas tinggi untuk membuat scrollbar */
|
25 |
-
overflow-y: auto; /* Scrollable secara vertikal */
|
26 |
-
background: transparent !important;
|
27 |
-
color: #ffffff !important;
|
28 |
-
border-radius: 12px;
|
29 |
-
padding: 20px;
|
30 |
-
text-align: center;
|
31 |
-
box-sizing: border-box;
|
32 |
-
}
|
33 |
-
|
34 |
-
.gradio-container .wrap h1 {
|
35 |
-
font-size: 100px !important; /* Adjust font size for the title */
|
36 |
-
font-family: 'Itim', cursive !important; /* Set title font to Itim */
|
37 |
-
font-weight: bold !important; /* Make the title bold */
|
38 |
-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); /* Add a shadow effect */
|
39 |
-
color: #000000 !important; /* Title color */
|
40 |
-
}
|
41 |
-
|
42 |
-
.gradio-container .wrap .description {
|
43 |
-
font-size: 60px !important; /* Adjust font size for the description */
|
44 |
-
font-family: 'Instrument Sans', sans-serif !important; /* Set description font to Instrument Sans */
|
45 |
-
font-weight: 400; /* Use normal font weight */
|
46 |
-
line-height: 1.5; /* Optional: Add line spacing */
|
47 |
-
color: #000000;
|
48 |
-
}
|
49 |
-
|
50 |
-
.output-textbox textarea {
|
51 |
-
background-color: #1e1e1e !important; /* Dark gray background for textbox */
|
52 |
-
color: #ffffff !important; /* White text */
|
53 |
-
border: 2px solid #000000;
|
54 |
-
font-weight: bold;
|
55 |
-
font-size: 16px;
|
56 |
-
padding: 10px;
|
57 |
-
border-radius: 8px;
|
58 |
-
}
|
59 |
-
|
60 |
-
/* CSS untuk tab "Home" dengan background biru */
|
61 |
-
.gradio-tab-item:nth-child(1) {
|
62 |
-
background-image: url('https://example.com/home-background.jpg') !important;
|
63 |
-
background-size: cover !important;
|
64 |
-
color: white !important;
|
65 |
-
}
|
66 |
-
|
67 |
-
/* CSS untuk tab "Coba Sekarang" dengan background oranye */
|
68 |
-
.gradio-tab-item:nth-child(2) {
|
69 |
-
background-image: url('https://example.com/coba-sekarang-background.jpg') !important;
|
70 |
-
background-size: cover !important;
|
71 |
-
color: white !important;
|
72 |
-
}
|
73 |
-
|
74 |
-
.gradio-container::-webkit-scrollbar {
|
75 |
-
width: 12px; /* Lebar scrollbar */
|
76 |
-
}
|
77 |
-
|
78 |
-
.gradio-container::-webkit-scrollbar-track {
|
79 |
-
background: rgba(255, 255, 255, 0.2); /* Warna latar belakang track */
|
80 |
-
border-radius: 6px; /* Membuat sudut melengkung */
|
81 |
-
}
|
82 |
-
|
83 |
-
.gradio-container::-webkit-scrollbar-thumb {
|
84 |
-
background: rgba(255, 165, 0, 0.8); /* Warna scrollbar (oranye transparan) */
|
85 |
-
border-radius: 6px; /* Membuat sudut melengkung */
|
86 |
-
border: 2px solid rgba(30, 144, 255, 0.5); /* Border dengan warna biru */
|
87 |
-
}
|
88 |
-
|
89 |
-
.gradio-container::-webkit-scrollbar-thumb:hover {
|
90 |
-
background: rgba(255, 165, 0, 1); /* Warna scrollbar saat hover */
|
91 |
-
border: 2px solid rgba(30, 144, 255, 1); /* Border lebih tegas saat hover */
|
92 |
-
}
|
93 |
-
"""
|
94 |
-
|
95 |
-
# Membuat antarmuka menggunakan Tabs
|
96 |
with gr.Blocks() as demo:
|
97 |
with gr.Tab("Home"):
|
98 |
-
gr.
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Fungsi untuk tab "Home"
|
4 |
+
def home_content():
|
5 |
+
return "Selamat datang di halaman Home!"
|
6 |
|
7 |
+
# Fungsi untuk tab "Coba sekarang"
|
8 |
+
def coba_sekarang_content():
|
9 |
+
return "Ini adalah halaman 'Coba sekarang'!"
|
10 |
|
11 |
+
# Membuat antarmuka dengan tab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
with gr.Blocks() as demo:
|
13 |
with gr.Tab("Home"):
|
14 |
+
with gr.Column():
|
15 |
+
gr.Markdown("### Home Page")
|
16 |
+
gr.Textbox(home_content, label="Home", elem_id="home_box")
|
17 |
+
|
18 |
+
with gr.Tab("Coba sekarang"):
|
19 |
+
with gr.Column():
|
20 |
+
gr.Markdown("### Coba sekarang")
|
21 |
+
gr.Textbox(coba_sekarang_content, label="Coba sekarang", elem_id="coba_sekarang_box")
|
22 |
+
|
23 |
+
# Menggunakan CSS untuk mengganti warna latar belakang tiap tab
|
24 |
+
demo.css = """
|
25 |
+
#home_box {
|
26 |
+
background-color: lightblue;
|
27 |
+
}
|
28 |
+
#coba_sekarang_box {
|
29 |
+
background-color: lightgreen;
|
30 |
+
}
|
31 |
+
"""
|
32 |
+
|
33 |
+
# Menjalankan aplikasi Gradio
|
34 |
demo.launch()
|