-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·123 lines (106 loc) · 4.61 KB
/
test.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python
import logging
import highgtk.app.staged
import highgtk.element.text
import highgtk.element.table
import highgtk.entity
import highgtk.data
import highgtk.constraint
import highgtk.control.manager
import highgtk.control.front
import highgtk.control.back
def test_execute():
print "execute"
class TestStage (highgtk.app.staged.Stage):
def __init__ (self, app):
highgtk.app.staged.Stage.__init__ (self, app, "Stage 1")
self.group = highgtk.entity.DocumentGroup (primary=True)
self.test5 = False
self.test6 = False
def _quit_ok (self, inquiry, results):
print results
def _quit_cancel (self, inquiry):
self.application.advance()
def run (self):
self.add (self.group)
self._setup_text()
self._setup_table()
self._setup_inquiry()
def _setup_inquiry (self):
data = (
( highgtk.data.Text ("id1", "Some text"), [ highgtk.constraint.Min (3) ] ),
( highgtk.data.Text ("id2", "Some other text"), None ),
( highgtk.data.HiddenText ("id3", "hidden text"), [ highgtk.constraint.Equal ("id2") ] ),
( highgtk.data.Boolean ("id3", "an option"), None )
)
self.inquiry = highgtk.entity.Inquiry (data)
self.inquiry.title = "Some Input, please!"
self.inquiry.ok_method = "_quit_ok"
self.inquiry.cancel_method = "_quit_cancel"
self.add (self.inquiry)
def _setup_text (self):
self.document = highgtk.entity.Document()
self.group.add (self.document)
self.view = highgtk.entity.View()
self._setup_controls (self.view)
self.document.add (self.view)
self.textdocument = highgtk.element.text.DocumentElement()
self.document.add (self.textdocument)
self.textview = highgtk.element.text.ViewElement (self.textdocument)
self.view.add (self.textview)
def _setup_table (self):
self.document2 = highgtk.entity.Document()
self.group.add (self.document2)
self.view2 = highgtk.entity.View()
self._setup_controls (self.view2)
self.document2.add (self.view2)
columns = ( highgtk.data.Text ("+ID", "text1"), highgtk.data.Boolean ("id2", "Option") )
self.tabledocument = highgtk.element.table.OrderedDocumentElement (columns)
self.tabledocument.reorder = 0
content = (
('some text', True ), ('more text', False ), ('and then some more', True ) )
content2 = (
('some text2', True ), ('more text', False ), ('and then some more', True ) )
self.tabledocument.update (content)
self.tabledocument.update (content2)
self.document2.add (self.tabledocument)
self.tableview = highgtk.element.table.ViewElement (self.tabledocument)
self.tableview.search = "+ID"
self.view2.add (self.tableview)
def _setup_controls (self, view):
view.control = highgtk.control.manager.Root (view)
view.control.create_group ("test", highgtk.control.front.Custom ("Test"))
view.control.create_group ("test3", highgtk.control.front.Custom ("Test3"),
parent="test", position=10)
view.control.create_interaction ("test2", highgtk.control.front.Custom ("Test2"),
test_execute, parent="test", position=0)
view.control.create_interaction ("test4", highgtk.control.front.Custom ("Add test5"),
self._add_test5, parent="test3")
view.control.create_interaction ("test4b", highgtk.control.front.Custom ("Add test6"),
self._add_test6, parent="test3")
def _add_test5 (self, view):
if not self.test5:
view.control.create_interaction ("test5", highgtk.control.front.Custom ("Remove self"),
self._remove_test5, parent="test3")
self.test5 = True
def _remove_test5 (self, view):
if self.test5:
view.control.remove ("test5")
self.test5 = False
def _add_test6 (self, view):
if not self.test6:
view.control.create_group ("test6", highgtk.control.front.Custom ("Test 6"),
parent="test3")
view.control.create_interaction ("test6b",
highgtk.control.front.Custom ("Remove parent group"),
self._remove_test6, parent="test6")
self.test6 = True
def _remove_test6 (self, view):
if self.test6:
view.control.remove ("test6")
self.test6 = False
if __name__=="__main__":
logging.basicConfig (level=logging.INFO)
app = highgtk.app.staged.Application ("Test")
app.stages.append (TestStage (app))
app.run()