[PyQt] More pythonic API

Phil Thompson phil at riverbankcomputing.com
Sat Aug 1 11:09:12 BST 2009


On Sat, 1 Aug 2009 11:55:59 +0200, Florian Friesdorf <flo at chaoflow.net>
wrote:
> On Sat, Aug 01, 2009 at 10:51:27AM +0100, Phil Thompson wrote:
>> On Sat, 1 Aug 2009 11:46:59 +0200, Florian Friesdorf <flo at chaoflow.net>
>> wrote:
>> >> > a = QAction()
>> >> > a.setEnabled(True)
>> >> > enabled = a.isEnabled()
>> >> > (..)
>> >> > 
>> >> > Preferably these would look something like:
>> >> > 
>> >> > a = QAction()
>> >> > a.enabled = True
>> >> > enabled = a.enabled
>> >> 
>> >> This is fairly easy to implement but would be an incompatible change.
>> > 
>> > I wouldn't like having my code rely on a specially built PyQt. Is it
>> > possible to generate these bindings as extra add-on modules?
>> 
>> They'd have to be replacements not add ons.
> 
> Only, iff there is a collision between those APIs, or?
> In the above example, at least, it should work to have them both,
> eventually using nasty monkey-patching.

Yes, but it isn't a typical example. Qt tends to use setThing() and
thing(), so the getter method would be incompatible with the property name.

Phil


More information about the PyQt mailing list