-
Notifications
You must be signed in to change notification settings - Fork 1
/
mvc_observer.py
47 lines (36 loc) · 1.48 KB
/
mvc_observer.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
#!/usr/bin/python
import gtk
import pygtk
import cairo
class MVCObserver(object):
"""
The MVCObserver class is the parent class of the specific observers (views and controllers) which are part of the Model-View-Controller (MVC) Architecture and inherit from this class. View are implementing the Graphical User Interface (GUI) and controller the interaction between the user and the data. Those observers can register with the model to receive notification events.
"""
_model = None
def __init__(self):
""" Constructor of MVCObserver and default values will be initialised. """
self._model = None
self._controller = None
def __init__(self, model = None):
""" Constructor of MVCObserver and default values will be initialised. """
self._model = model
if self._model != None:
self._model.add(self)
@property
def model(self):
""" Return model (MVCObservable-Object). """
return self._model
@model.setter
def model(self, model):
""" Set model (MVCObservable-Object). """
self._model = model
# check if observer object can be registered
if self._model != None:
# register observer
self._model.add(self)
def update(self):
""" Interface to notify MVCObserver objects about a general data change. """
pass
def reset(self):
""" Interface to notify MVCObserver objects about a reset event. """
pass