[PyQt] properties and interfaces with dip 0.3

Lic. José M. Rodriguez Bacallao jmrbcu at gmail.com
Wed Jul 13 21:18:28 BST 2011


must the getter method is supposed to be called no, is a getter!!!

On Wed, Jul 13, 2011 at 3:49 PM, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> On Wed, 13 Jul 2011 15:17:48 -0400, Lic. José M. Rodriguez Bacallao
> <jmrbcu at gmail.com> wrote:
>> in this example:
>>
>> class ITest(Interface):
>>     id = Str()
>>
>> @implements(ITest)
>> class Test(Model):
>>
>>     @ITest.id.getter
>>     def id(self):
>>         return 'getting id'
>>
>>     @ITest.id.setter
>>     def id(self, v):
>>         print 'setting id'
>>
>>     @observe('id')
>>     def on_change(self, change):
>>         print 'changing...'
>>
>>     test = Test()
>>     test.id = 'xxx'
>>     print test.id
>>
>> in the case of properties, it is necessary to use the syntax:
>> @Interface.attr but here I got another problem, the getter are not
>> being called. Why?
>
>    @id.setter
>    def id(self, v):
>
> Python properties work in exactly the same way.
>
> Phil
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-----------------------------------------------------------------
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-----------------------------------------------------------------


More information about the PyQt mailing list