-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sample_web_interface.py
39 lines (35 loc) · 1.64 KB
/
test_sample_web_interface.py
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
import webio, time;
from webio import Action, Div, HDiv, HTabs, Tab, TitleText, Button, TextInput
from webio import TextArea, VSpace, Tab, HTabs, Card, Text;
class MyWebsite:
tabs = ["Home", "About", "Contact", "Dashboard"];
content_for_tabs = {0: ["Home-01", "Home-02"], 1: ["About-11", "About-12"],
2: ["Contact-01"], 3: ["Dashboard-01"]};
def __init__(self):
self.current_tab = 0;
def Render(self):
frame = Div();
frame << TitleText("Welcome to webio") << VSpace("20px");
frame << HTabs((Tab(self.tabs[index],
onclick = Action(lambda index: self.set_current_tab(index),
index)
) for index in range(len(self.tabs))),
padding = "0px 0px 0px 10px",
selected_tab = self.current_tab
);
frame << VSpace("10px")
for c in self.content_for_tabs[self.current_tab]:
frame << Card(c, color = ("blue" if self.current_tab == 2 else "default"),
width = "50%");
frame << VSpace("20px");
Text("Want to create more content ?", font_size = "16px",
margin = "5px");
frame << TextInput("Your Name ?") << TextArea("Your content goes here",
id = "content");
frame << Button("Submit", onclick =
lambda: (self.content_for_tabs[self.current_tab].append(
self.inputs["content"])));
return frame;
def set_current_tab(self, index):
self.current_tab = index;
webio.Serve(MyWebsite, port=5002);