[PyQt] More pythonic API

Florian Friesdorf flo at chaoflow.net
Wed Jul 29 13:44:54 BST 2009


Hello,

Based on a longer python history and no Qt experience, I'm just starting
with PyQt. My enthusiasm is a bit slowed down by the non-pythonic API:

a = QAction()
a.setEnabled(True)
enabled = a.isEnabled()

setting = QSettings()
filename = 'some.file'
qfilename = QVariant(QString(filename))
settings.setValue("LastFile", qfilename)
filename = settings.value("LastFile").toString()

Preferably these would look something like:

a = QAction()
a.enabled = True
enabled = a.enabled

settings = QSettings()
filename = 'some.file'
settings["LastFile"] = filename
filename = settings["LastFile"]


One thing here is the implicit use of __getitem__() and __setitem__()
instead of two different explicit functions. The other is a translation
of QVariant to string and vice versa.

- Are there any wrappers available that translate to a more
  pythonic API, i.e. not just direct bindings?
- Could SIP be extended to create these, i.e. would it be
  sane to have SIP extended to create these?
- Are there any plans to work towards a more pythonic API?
- Am I the only one getting cognitive dissonance when programming with
  the less pythonic versions?


best regards
florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090729/c3701f2a/attachment.bin


More information about the PyQt mailing list