Closed Nodd closed 8 years ago
I tried that workflow and did not like it that much to be honest, it adds an extra step and an extra software to make any tweak (Qt Designer). I think ui files are a great alternative when you code in C++ but on python it feels like extra baggage.
I think is better to write the code in a way that the __init__
only handles UI element configuration and any other setup... in a setup step.... (this is the best you can achieve for MVC, in Qt which does not really enforce MVC that much...)
@Nodd, I think a proof of concept pull request would be a good place to start with this :-)
What is the question again??!?!?
@goanpeca I know it's not a workflow that you like. I don't want to force it, just to give the possibility to use it in qtpy by adding a single loadUi
function.
As for the workflow itself, I view it more like a way to separate the view (.ui) and the controller (.py) in MVC terms. Also I like to see directly the interface I build. Since I mostly build non modular interfaces, having everything in a single .ui file is not a problem. It is indeed less suited for spyder for example.
Ahhhh ok ok, sorry I did not understand. Sure lets do it!
The unfortunate thing is that Qt is not really MVC, only some parts and even then the mixture is all over the place... so that is more like wishful thinking :p
I tried it, but there is a problem I didn't anticipated: .ui files are not fully between Qt4 and Qt5, so I don't know if it's really worth it. I'll list some reference for documentation:
PyQt4.uic.loadUi
for PySide. I don't know who did the first implementation:
And here's a slightly modified implementation of loadUi for PySide that we use for Glue based on some of the other ones given above: https://github.com/glue-viz/qt-helpers/blob/master/qt_helpers.py#L383 (I cleaned up and removed some unnecessary parts)
Thanks @astrofrog! Would it be ok for you to work under qtpy
as a common library that's used by all Python scientific projects based on Qt?
I say it because we're going to migrate Spyder to use it in a month or so, and it'd be great if Glue would like to join us :-)
@ccordoba12 - I think it'd be great to use qtpy
, so I'll look into it. I'll open some more issues for things I can contribute and turn into pull requests.
@ccordoba12 - would you like a PR for the loadUi patch?
Sure, please go for it! We'll also be glad to merge other PRs that are helpful for Glue.
We built qtpy mostly for Spyder (as you can guess), but we want to work with the community to make it useful for everybody :-)
When using
.ui
files to build an interface graphically with QtDesigner, it is possible to load the interface directly from the.ui
file rather than having to transform it onto python then import it. This is already integrated into PyQt4 and PyQt5, and relatively easy to implement in PySide as seen in python_qt_binding, the concurrent that doesn't support Qt5.I know it's not the workflow used in spyder, but it would be a great utility for some projects (including mine).