-
Notifications
You must be signed in to change notification settings - Fork 16
/
EXAMPLE-OptionList.py
executable file
·43 lines (29 loc) · 1.35 KB
/
EXAMPLE-OptionList.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
#!/usr/bin/env python
# encoding: utf-8
# The system here is an experimental one. See documentation for details.
import npyscreen
class TestApp(npyscreen.NPSApp):
def main(self):
Options = npyscreen.OptionList()
# just for convenience so we don't have to keep writing Options.options
options = Options.options
options.append(npyscreen.OptionFreeText('FreeText', value='', documentation="This is some documentation."))
options.append(npyscreen.OptionMultiChoice('Multichoice', choices=['Choice 1', 'Choice 2', 'Choice 3']))
options.append(npyscreen.OptionFilename('Filename', ))
options.append(npyscreen.OptionDate('Date', ))
options.append(npyscreen.OptionMultiFreeText('Multiline Text', value=''))
options.append(npyscreen.OptionMultiFreeList('Multiline List'))
try:
Options.reload_from_file('/tmp/test')
except FileNotFoundError:
pass
F = npyscreen.Form(name = "Welcome to Npyscreen",)
ms = F.add(npyscreen.OptionListDisplay, name="Option List",
values = options,
scroll_exit=True,
max_height=None)
F.edit()
Options.write_to_file('/tmp/test')
if __name__ == "__main__":
App = TestApp()
App.run()