From e3633a2cc4a5aa061172f4962da86ce346151ff8 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 16 Apr 2009 20:52:21 +0000 Subject: LP 348570 Core : Integrating properties to actions; adding tests --- (limited to 'src/sugar/tutorius/actions.py') 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): """ -- cgit v0.9.1