diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-04-16 20:52:21 (GMT) |
---|---|---|
committer | mike <michael.jmontcalm@gmail.com> | 2009-04-16 20:52:21 (GMT) |
commit | e3633a2cc4a5aa061172f4962da86ce346151ff8 (patch) | |
tree | e12948a10b6dbb302d4e2fbfd92d8fa92ea2437a /src/sugar/tutorius/actions.py | |
parent | 0cad6dc96afc2ebd4d03beb14ed01bc155dfa322 (diff) |
LP 348570 Core : Integrating properties to actions; adding tests
Diffstat (limited to 'src/sugar/tutorius/actions.py')
-rw-r--r-- | src/sugar/tutorius/actions.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py index b8c21e0..fc364e0 100644 --- a/src/sugar/tutorius/actions.py +++ b/src/sugar/tutorius/actions.py @@ -29,6 +29,7 @@ class Action(object): """Base class for Actions""" def __init__(self): object.__init__(self) + self.properties = {} def do(self, **kwargs): """ @@ -43,12 +44,12 @@ class Action(object): pass #Should raise NotImplemented? def get_properties(self): - if not hasattr(self, "_props") or self._props is None: - self._props = [] + if self.properties is None or len(self.properties) == 0: + self.properties = {} for i in dir(self): if isinstance(getattr(self,i), TutoriusProperty): - self._props.append(i) - return self._props + self.properties[i] = getattr(self,i) + return self.properties.keys() class OnceWrapper(object): """ @@ -89,14 +90,12 @@ class DialogMessage(Action): @param message A string to display to the user @param pos A list of the form [x, y] """ - def __init__(self, message, pos=[0,0]): + def __init__(self, message, pos=None): super(DialogMessage, self).__init__() - self._message = message - self._position = pos self._dialog = None - self.message = TStringProperty("") - self.position = TArrayProperty([0,0], 2) + self.message = TStringProperty(message) + self.position = TArrayProperty(pos or [0, 0], 2, 2) def do(self): """ |