From c7957e876fdc012af627f0cfacca019daffbbaad Mon Sep 17 00:00:00 2001 From: isen Date: Fri, 25 Sep 2009 03:44:47 +0000 Subject: propriété position, tuple de deux int (sans contraintes) --- diff --git a/addons/bubblemessage.py b/addons/bubblemessage.py index a859ef8..b61a356 100644 --- a/addons/bubblemessage.py +++ b/addons/bubblemessage.py @@ -21,7 +21,10 @@ class BubbleMessage(Action): position = TArrayProperty([0,0], 2, 2) # Do the same for the tail position tail_pos = TArrayProperty([0,0], 2, 2) - + # + # ?:;:.? + # + test = TPositionProperty((0,0)) def __init__(self, message=None, pos=None, speaker=None, tailpos=None): """ Shows a dialog with a given text, at the given position on the screen. diff --git a/tutorius/constraints.py b/tutorius/constraints.py index 36abdfb..f2e324f 100644 --- a/tutorius/constraints.py +++ b/tutorius/constraints.py @@ -204,4 +204,14 @@ class FileConstraint(Constraint): if not os.path.isfile(value): raise FileConstraintError("Non-existing file : %s"%value) return - + +class SameTypeConstraint(Exception): + pass + +class SameTypeConstraint(ValueConstraint): + pass + #def validate(self, typePropertie): + # if self.limit != typePropertie: + # raise SameTypeConstraint("Value with a diffferent type") + #return + diff --git a/tutorius/properties.py b/tutorius/properties.py index 7423d25..9db600e 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -310,5 +310,31 @@ class TAddonProperty(TutoriusProperty): if isinstance(value, TPropContainer): return super(TAddonProperty, self).validate(value) raise ValueError("Expected TPropContainer instance as TaddonProperty value") + + +class TPositionProperty(TutoriusProperty): + """ + Represents a tuple of two int. The first value is the x position and the second the y position + """ + def __init__(self, (x, y)): + TutoriusProperty.__init__(self) + self.type = "position" + self._x=x or 0 + self._y=y or 0 + self.default = self.validate((self._x,self._y)) + #voir les contraintes ou créer x en TintProperty + + +#class TArrayOneTypeProperty(TutoriusProperty): +# """ +# Represents an array list of properties. Can have a maximum number of element +# limit. All the elements in the list must have the same type. +# """ +# def __init__(self, value, min_size_limit=None, max_size_limit=None): +# TutoriusProperty.__init__(self) +# self.max_size_limit = MaxSizeConstraint(max_size_limit) +# self.min_size_limit = MinSizeConstraint(min_size_limit) +# self.type = SameTypeConstraint(self.type) +# self.default = self.validate(value) -- cgit v0.9.1