-
Notifications
You must be signed in to change notification settings - Fork 109
/
TESTING-TreeMultiLineBox.py
executable file
·46 lines (34 loc) · 1.42 KB
/
TESTING-TreeMultiLineBox.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
#!/usr/bin/env python
RETURN = []
import npyscreen
class SelectableTreeLine(npyscreen.TreeLineSelectableAnnotated):
def calculate_area_needed(self):
"Need two lines of screen, and any width going"
return 2,0
class TestTree(npyscreen.MLTreeMultiSelect):
_contained_widgets = SelectableTreeLine
_contained_widget_height = 2
class TestApp(npyscreen.NPSApp):
def main(self):
F = npyscreen.Form(name = "Testing Tree class",)
#wgtree = F.add(npyscreen.MLTree)
wgtree = F.add(TestTree)
treedata = npyscreen.NPSTreeData(content='Root', selectable=True,ignoreRoot=False)
c1 = treedata.newChild(content='Child 1', selectable=True, selected=True)
c2 = treedata.newChild(content='Child 2', selectable=True)
g1 = c1.newChild(content='Grand-child 1', selectable=True)
g2 = c1.newChild(content='Grand-child 2', selectable=True)
g3 = c1.newChild(content='Grand-child 3')
gg1 = g1.newChild(content='Great Grand-child 1', selectable=True)
gg2 = g1.newChild(content='Great Grand-child 2', selectable=True)
gg3 = g1.newChild(content='Great Grand-child 3')
wgtree.values = treedata
F.edit()
global RETURN
#RETURN = wgtree.values
RETURN = wgtree.get_selected_objects()
if __name__ == "__main__":
App = TestApp()
App.run()
for v in RETURN:
print v