Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/properties.py
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius/properties.py')
-rw-r--r--tutorius/properties.py42
1 files changed, 37 insertions, 5 deletions
diff --git a/tutorius/properties.py b/tutorius/properties.py
index 7423d25..65059b2 100644
--- a/tutorius/properties.py
+++ b/tutorius/properties.py
@@ -20,10 +20,7 @@ also use the TPropContainer), with the added benefit of having builtin dialog
prompts and constraint validation.
"""
-from sugar.tutorius.constraints import Constraint, \
- UpperLimitConstraint, LowerLimitConstraint, \
- MaxSizeConstraint, MinSizeConstraint, \
- ColorConstraint, FileConstraint, BooleanConstraint, EnumConstraint
+from sugar.tutorius.constraints import *
from copy import copy
class TPropContainer(object):
@@ -207,8 +204,12 @@ class TArrayProperty(TutoriusProperty):
self.type = "array"
self.max_size_limit = MaxSizeConstraint(max_size_limit)
self.min_size_limit = MinSizeConstraint(min_size_limit)
+ self.indexeur = value #stock la value, pour l'indexation
self.default = self.validate(value)
-
+
+ #def __getitem__(self, key): # obligation de redéfinir l'indexation
+ # return self.indexeur[key] #
+
class TColorProperty(TutoriusProperty):
"""
Represents a RGB color with 3 8-bit integer values.
@@ -310,5 +311,36 @@ 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
+ #convertir en int ou raise error idem sur Tintproperty
+
+ #contrainte générique du style is 'type' qui essai de convertir les éléments d'une séquence
+
+ #contraintes deux élements
+
+
+class TArrayOneTypeProperty(TArrayProperty):
+ """
+ Represents an array list of properties. Can have a maximum (and/or minimum) number of element
+ limit. All the elements in the list must have the same type. The list must not be empty
+ """
+ def __init__(self, value, min_size_limit=None, max_size_limit=None):
+ TArrayProperty.__init__(self, value, min_size_limit, max_size_limit)
+ self.type = "typedlist"
+ self.required_type = SameTypeConstraint()
+ self.default = self.validate(value)
+