[go: up one dir, main page]

Menu

[390b88]: / ui / view.py  Maximize  Restore  History

Download this file

56 lines (41 with data), 1.1 kB

 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
'''View abstraction and discovery.'''
class View:
'''Base class for model views.'''
def __init__(self, model):
self.model = model
def get_name(self):
'''Get the name of this view.'''
raise NotImplementedError
def destroy(self):
'''Destroy this view.'''
raise NotImplementedError
class ViewFactory:
'''Base class for model views factories.'''
def __init__(self):
pass
def get_name(self):
'''The name of the created views.'''
raise NotImplementedError
def can_create(self, model):
'''Whether a view can be created for this model.'''
raise NotImplementedError
def create(self, model):
'''Create a view for this model.'''
raise NotImplementedError
def main(cls):
'''Simple main function to test views.'''
import sys
import gtk
import aterm.factory
import ui.model
factory = aterm.factory.factory
if len(sys.argv) > 1:
fp = file(sys.argv[1], 'rb')
else:
fp = sys.stdin
term = factory.readFromTextFile(fp)
model = ui.model.Model()
model.set_term(term)
view = cls(model)
view.connect('destroy', gtk.main_quit)
gtk.main()