Feature #189: GUI: implement prototype(s), decide about architecture
Implement PyQt4 prototype
|Status:||Rejected||Start date:||26 Apr 2013|
Write PyQt GUI prototype which fully reproduces the functionality of our existing C++ GUI
- requires investigation of SIP technology for Python bindings
- requires investigation of scientific graphics in Python (matplotlib, WebGL, ROOT or something else)
- study mature PyQt projects
#4 Updated by pospelov about 7 years ago
- % Done changed from 0 to 10
The development of py-qt prototype has been started in ./BornAgain/GUI/pytgui. The initial ideas was to reproduce the functionality of existing BornAgain C++ prototype using python. Since our C++ GUI uses complicated custom Qt widgets, it was decided not to port them on pure Python (too much work), but compile them into separate library and use this library from python. Given approach is used in Avogadro and Orange frameworks, so we were not reinventing the wheel.
This goal has been partly achieved. C++ Qt widgets were compiled with boost-python into the library which can be imported in Python in such way, that PyQt widgets communicate via boost-python with C++ Qt widgets.
Unfortunately, some bugs are still there and our first PyQt application still crashes.
The technical problem here, as usual, the ownership of objects. Qt originally was not created for python. Qt widgets often owns other Qt widgets and take care about they deletion. Python also owns all objects and takes care about they deletion. PyQt is the guy, who resolve this problem and takes care about passing ownership from PyQt to Qt and back.
When we tried to extend PyQt with our custom C++ widgets, we had to deal with the same problem of correct passing of ownership. So far there is a bug somewhere.
0) try to find the bug and continue as before (C++ Qt <-> boost/python <-> PyQt gui)
1) Not to use custom C++ Qt widgets at all. Always write bare python PyQt code.
2) Try to expose C++ Qt widgets in python, as we already tried, but using another approach (SIP).
3) Continue with C++ gui development.
I'm taking a pause with this issue. It's free now.