[PyQt] dip properties
Phil Thompson
phil at riverbankcomputing.com
Tue Mar 13 13:49:11 GMT 2012
On Tue, 13 Mar 2012 08:23:26 -0500, José M. Rodriguez Bacallao
<jmrbcu at gmail.com> wrote:
> yes, I know that, the problem is that I want to shorten the code. For
> example, I want to do this:
>
> class Widget(QtGui.QWidget, Model):
> id = property(lambda self: self.objectName(), lambda self, v:
> self.setObjectName(v))
>
> instead of this:
>
> class Widget(QtGui.QWidget, Model):
> id = Str()
>
> @id.getter
> def id(self):
> return self.objectName()
>
> @id.setter
> def id(self, value):
> self.setObjectName(value)
So something like...
class Widget(QtGui.QWidget, Model):
id = Str(getter=lambda self: self.objectName(), setter=lambda self, v:
self.setObjectName(v))
???
I think that would be trivial to add.
Phil
More information about the PyQt
mailing list