From f80de2005006759be482bd82979ed073d1f7d978 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Fri, 5 Nov 2010 22:47:12 -0400 Subject: [PATCH] properties: allow python to get the name of the properties --- kivy/c_ext/properties.pyx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kivy/c_ext/properties.pyx b/kivy/c_ext/properties.pyx index 6be089639..17da3210a 100644 --- a/kivy/c_ext/properties.pyx +++ b/kivy/c_ext/properties.pyx @@ -5,13 +5,13 @@ cdef class Property: setter and getter, None handling, and observers. ''' - cdef str name + cdef str _name cdef int allownone cdef object defaultvalue cdef dict storage def __cinit__(self): - self.name = '' + self._name = '' self.allownone = 0 self.defaultvalue = None self.storage = {} @@ -20,6 +20,10 @@ cdef class Property: self.defaultvalue = defaultvalue self.allownone = kw.get('allownone', 0) + property name: + def __get__(self): + return self._name + cdef init_storage(self, dict storage): storage['value'] = self.defaultvalue storage['allownone'] = self.allownone @@ -27,7 +31,7 @@ cdef class Property: cpdef link(self, object obj, str name): d = dict() - self.name = name + self._name = name self.init_storage(d) self.storage[obj.__uid] = d