[PyQt] properties and interfaces with dip 0.3

Phil Thompson phil at riverbankcomputing.com
Wed Jul 13 18:35:56 BST 2011


On Wed, 13 Jul 2011 12:09:37 -0400, Lic. José M. Rodriguez Bacallao
<jmrbcu at gmail.com> wrote:
> hi folks, may be this is an fool question but, how to implement
> properties with interface attributes, for example, this doesn't work:
> 
> class SomeObject(object):
>     def __init__(self, id):
>         self.id = id
> 
> class ISomething(Interface):
>     id = Str()
> 
> class Somthing(Interface):
> 
>     _internal = Instance(SomeObject)
> 
>     @ISomething.id.getter
>     def id(self):
>         return self._internal.id
> 
>     @ISomething.id.setter
>     def id(self, value):
>         return self._internal.id = value
> 
>     @_internal.default
>     def _internal(self):
>         return SomeObject(self.id)

Whether the attributes of an interface have getters and setters is part of
the detail of a particular implementation of that interface. It's not part
of the specification of the interface.

You seem to be thinking of an interface as a base class - it isn't.

Phil


More information about the PyQt mailing list