File size: 2,483 Bytes
7798609 |
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
'''
title: Radio
'''
import simplestart as ss
ss.md("## ss.radio")
ss.space()
ss.md('''
#### π
Example
''')
def onchange(event):
ss.session["options_value"] = event.value
ss.session["options_index"] = event.index
ss.md("onchange: value:@options_value, index:@options_index")
options = ["Option 1", "Option 2", "Option 3"]
myradio = ss.radio(options, label = "### my radio1", index = 0, onchange = onchange)
'''
options = [("C++", '#### <span style="color:blue">C++</span>'),
("Javascript", '#### <span style="color:green">Javascript</span>'),
("Python", '#### <span style="color:red">Python</span>')
]
'''
options = [{'name':'#### <span style="color:blue">C++</span>', 'value':'C++'},
{'name':'#### <span style="color:green">Javascript</span>', 'value':'Javascript'},
{'name':'#### <span style="color:red">Python</span>', 'value':"Python"}
]
ss.radio(options, inline = True, label = "### my radio2", index = 0, iconColor = "blue", onchange = onchange)
ss.write("---")
ss.write("#### π Code")
ss.md('''
```python
import simplestart as ss
def onchange(event):
ss.session["options_value"] = event.value
ss.session["options_index"] = event.index
ss.md("onchange: value:\@options_value, index:\@options_index")
options = ["Option 1", "Option 2", "Option 3"]
myradio = ss.radio(options, label = "### my radio1", index = 0, onchange = onchange)
options = [{'name':'#### <span style="color:blue">C++</span>', 'value':'C++'},
{'name':'#### <span style="color:green">Javascript</span>', 'value':'Javascript'},
{'name':'#### <span style="color:red">Python</span>', 'value':"Python"}
]
ss.radio(options, inline = True, label = "### my radio2", index = 0, iconColor = "blue", onchange = onchange)
def onPageLoad():
ss.session["options_value"] = ""
''')
ss.space()
ss.md('''
---
#### π
Example - Get State Value
''')
def myclick1():
ss.message(myradio.value)
ss.button("Get State Value", onclick=myclick1)
def myclick2():
ss.message(myradio.index)
ss.button("Get State Index", onclick=myclick2)
ss.write("---")
ss.write("#### π Code Snippet")
ss.md('''
```python
#...
def myclick1():
ss.message(myradio.value)
ss.button("Get State Value", onclick=myclick1)
def myclick2():
ss.message(myradio.index)
ss.button("Get State Index", onclick=myclick2)
''')
def onPageLoad():
ss.session["options_value"] = "" |