Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
head="""
|
3 |
+
<script>
|
4 |
+
function open_control() {
|
5 |
+
var panel = document.querySelector('#control_panel');
|
6 |
+
|
7 |
+
var split_json = []
|
8 |
+
var out_json = []
|
9 |
+
split_json = panel.classList.value.split(' ')
|
10 |
+
|
11 |
+
console.log(split_json.length)
|
12 |
+
if (split_json.length === 2 || panel.classList.value.includes(" ")) {
|
13 |
+
panel.classList.toggle('open');
|
14 |
+
console.log('clicked')
|
15 |
+
} else {
|
16 |
+
panel.classList = '.contain #control_panel'
|
17 |
+
console.log('panel is open, closing')
|
18 |
+
|
19 |
+
};
|
20 |
+
};
|
21 |
+
|
22 |
+
</script>
|
23 |
+
"""
|
24 |
+
css="""
|
25 |
+
.contain #control_panel {
|
26 |
+
position: fixed;
|
27 |
+
right: 100%;
|
28 |
+
z-index: 9999;
|
29 |
+
width: 90%;
|
30 |
+
top: 50px;
|
31 |
+
}
|
32 |
+
.contain #control_panel.open {
|
33 |
+
right: 10%;
|
34 |
+
}
|
35 |
+
#top_bar {
|
36 |
+
height: 50px;
|
37 |
+
width: 100%;
|
38 |
+
position: fixed;
|
39 |
+
background: aliceblue;
|
40 |
+
top: 0px;
|
41 |
+
left: 0px;
|
42 |
+
z-index: 99999;
|
43 |
+
}
|
44 |
+
#control_btn {
|
45 |
+
height: 20px;
|
46 |
+
padding: 10px;
|
47 |
+
cursor: pointer;
|
48 |
+
border-radius: 5px;
|
49 |
+
color: white;
|
50 |
+
position: fixed;
|
51 |
+
z-index: 9999999999999999;
|
52 |
+
top: 5px;
|
53 |
+
left: 10px;
|
54 |
+
background: #1e293b;
|
55 |
+
height: fit-content;
|
56 |
+
width: fit-content;
|
57 |
+
}
|
58 |
+
"""
|
59 |
+
|
60 |
+
with gr.Blocks(head=head,css=css) as app:
|
61 |
+
gr.HTML("""<div id='top_bar'><div class='control_btn' name='control_btn' id='control_btn' onclick='open_control()'>Controls</div></div>""")
|
62 |
+
with gr.Group(elem_id="control_panel"):
|
63 |
+
gr.Textbox()
|
64 |
+
gr.Slider()
|
65 |
+
gr.RadioGroup()
|
66 |
+
|
67 |
+
app.launch()
|