/
radio.py
64 lines (48 loc) · 1.54 KB
/
radio.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from epyk.core.Page import Report
from epyk.core.data import components
from epyk.mocks import urls as data_urls
# TODO add Js events and also improve fwk to add click from labels
# Create a basic report object
page = Report()
page.headers.dev()
#
data = page.py.requests.csv(data_urls.AIRPORT_TRAFFIC)
#
page.body.style.css.padding = "0 20px"
# Console component
c = page.ui.rich.console("* This is a log section for all the events in the different buttons *", options={"timestamp": True})
#
radio_data = components.radio.from_records(data, 'city')
page.ui.radio(radio_data)
# Add a group of radio buttons
c1 = page.ui.fields.radio(True, label="Check 1", group_name="group1")
c2 = page.ui.fields.radio(True, label="Check 2", group_name="group1")
# Add a checked radio button
c3 = page.ui.inputs.radio(True, label="Check")
# Add a tick HTML component
c4 = page.ui.icons.tick(False, "Check")
# Add a list with radions buttons
c5 = page.ui.lists.radios([
{"value": True, 'text': 'Python'},
{"value": False, 'text': 'Javascript'},
])
c1.click([
c.dom.write(c1.dom.content),
c.dom.write(c1.dom.selected),
c.dom.write(c3.dom.val, stringify=True)
])
# Click even
page.ui.button("click").click([
c.dom.write(c4.dom.val, stringify=True),
c.dom.write(c5.dom.content),
# Check the value C1
c1.js.check()
])
page.ui.button("Uncheck C1").click([
# uncheck the value C1
c1.js.uncheck(),
# Change the label of the tick component
c4.span.build("New Label"),
# Change the color CSS property of the internal label
c4.span.dom.css({"color": 'red'})
])