[PyQt] More pythonic API

Arve Knudsen arve.knudsen at gmail.com
Wed Jul 29 14:53:01 BST 2009


My impression is that Phil intends for PyQt to generally resemble Qt as
closely as practically feasible. This approach has advantages. It implies
less complexity wrapping-wise, since the mapping is mostly direct, and once
you know Qt itself you can easily work with PyQt (principle of least
surprise). I find that PyQt being non-Pythonic mostly represents a
threshold, which has little practical bearing once you have some experience
with (Py)Qt. Also, it's a good thing when switching back and forth between
C++ and Python (which some of us do).

Arve

On Wed, Jul 29, 2009 at 2:44 PM, Florian Friesdorf <flo at chaoflow.net> wrote:

> 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
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090729/429792ed/attachment.html


More information about the PyQt mailing list