Would some global shim help the transition to Qt5 and PySide2 for module developers?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby qingfeng.xia » Thu Feb 02, 2017 10:38 am

There are some implementations for code comptatible: PySide, PySide2, PyQt4 and PyQt5
I see there is a qt5_pyside2 build , but what I know, Fem Cfd workbench still using PySide, some of code is not compatible with Qt5

1. qt_compat.py in matplotlib
2. qtpy: https://github.com/mottosso/Qt.py#usage
https://github.com/spyder-ide/qtpy
3. another shim on pypi, I forget the name, it can do `from anypyqt import QtCore`

Module dev, can safely assume,
QtGui, QtWidgets(a alias to QtGui for Qt4) are already there,

Or, we can alias pyside2 into PySide, so we can assume PySide is always there?
Ubuntu 0.17-dev OpenFOAM + FreeCAD
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby qingfeng.xia » Sun Mar 05, 2017 3:59 pm

example code

Code: Select all


from Qt import QtCore, QtWidgets, QtGui
#from qtpy mport QtCore, QtWidgets, QtGui


from Qt import __binding__
if __binding__ in ('PySide2', 'PyQt5'):
    print('Qt5 binding available')
elif __binding__ in ('PySide', 'PyQt4'):
    print('Qt4 binding available.')
else:
    print('No Qt binding available.')

from QtCore import pyqtSlot  #fine
from QtGui import QIcon
from QtWidgets import QApplication, QWidget, QPushButton, QMessageBox



I believe it will be good for module developers.
Because, we know QtCore and QtGui must be imported by FreeCAD already, current from PySide import XXX can be avoided for mx comptabiility.
Ubuntu 0.17-dev OpenFOAM + FreeCAD
blacey
Posts: 337
Joined: Tue Dec 08, 2015 11:28 pm

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby blacey » Sun Mar 05, 2017 4:14 pm

@wmayer has already implemented a small pyside shim.
User avatar
yorik
Site Admin
Posts: 8553
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby yorik » Sun Mar 05, 2017 6:34 pm

I still cannot compile pyside2.. grr... everytime i try there is another error I'm too lazy to go after.
blacey
Posts: 337
Joined: Tue Dec 08, 2015 11:28 pm

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby blacey » Sun Mar 05, 2017 6:40 pm

yorik wrote:I still cannot compile pyside2.. grr... everytime i try there is another error I'm too lazy to go after.


Yorik,

On Linux or Windows? If Windows, you might want to checkout @wmayer's post

You also might want to try these versions of pyside2 - this is what we are currently using on macOS with Qt 5.6.2.

shiboken2 download
pyside2 download

In each of the formula, you can also see the build options that we use.

Perhaps you could post the compilation errors.
User avatar
yorik
Site Admin
Posts: 8553
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby yorik » Sun Mar 05, 2017 11:48 pm

I'm on linux. Thanks for the configs bruce, I'll look at what you used and try again
I was using the pyside-setup repo from http://code.qt.io/cgit/pyside/pyside-setup.git/tree/
which automatically pulls and builds both shiboken2 and pyside2... But I see now there are appveyor and travis badges in the readme, and one of them is failing. There might be some temporary error, I'll check again tomorrow
blacey
Posts: 337
Joined: Tue Dec 08, 2015 11:28 pm

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby blacey » Sun Mar 05, 2017 11:57 pm

yorik wrote:I'm on linux. Thanks for the configs bruce, I'll look at what you used and try again
I was using the pyside-setup repo from http://code.qt.io/cgit/pyside/pyside-setup.git/tree/
which automatically pulls and builds both shiboken2 and pyside2...


I was originally trying with pyside-setup and @f3nix suggested that I circumvent it and install shiboken, pyside and pyside-tools directly which I did. In fact, in looking at it closely, using pyside-setup actually installs older versions of each (i.e. the sub-repos are not installed at the HEAD sha).

yorik wrote:But I see now there are appveyor and travis badges in the readme, and one of them is failing. There might be some temporary error, I'll check again tomorrow


The Travis issue should be solved. We had a namespace clash between the legacy formulae and the newer formulae that we developed for pyside2 so I worked with the Qt 4 maintainer and submitted a PR to rename the legacy formulae. The maintainer merged them today so I had to update the Travis config accordingly which is done so the Travis badge should be green ;)

@f3nix, I know you are slinging different versions of Qt 5 on Linux so can you give Yorik some pyside2 install tips/hints/instructions?
User avatar
yorik
Site Admin
Posts: 8553
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby yorik » Mon Mar 06, 2017 5:20 pm

blacey wrote:I was originally trying with pyside-setup and @f3nix suggested that I circumvent it and install shiboken, pyside and pyside-tools directly which I did

Aha, will try that instead. Thanks for the hint!
User avatar
f3nix
Posts: 213
Joined: Sat May 30, 2015 11:58 am

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby f3nix » Mon Mar 06, 2017 7:00 pm

Hi yorik!

Could you please tell us your build config? Qt version/linux version.

Cheers,
Mateusz
User avatar
yorik
Site Admin
Posts: 8553
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Would some global shim help the transition to Qt5 and PySide2 for module developers?

Postby yorik » Mon Mar 06, 2017 10:05 pm

H f3nix,
thanks for the help offer! I am on debian with qt5.7. Took the pyside-setup repo, indeed the pyside2 inside was not up to date... So I cloned the shiboken2 and pyside2 separately, shiboken compiled and installed successfully, then pyside2 (just ran standard cmake with no option, no complaints) then this error when making:

Code: Select all

[  3%] Building CXX object PySide2/QtCore/CMakeFiles/QtCore.dir/PySide2/QtCore/qxmlstreamentitydeclaration_wrapper.cpp.o
/home/yorik/Sources/pyside2/build/PySide2/QtCore/PySide2/QtCore/qxmlstreamentitydeclaration_wrapper.cpp: In function ‘int Sbk_QXmlStreamEntityDeclaration_Init(PyObject*, PyObject*, PyObject*)’:
/home/yorik/Sources/pyside2/build/PySide2/QtCore/PySide2/QtCore/qxmlstreamentitydeclaration_wrapper.cpp:124:58: error: no match for ‘operator*’ (operand type is ‘QXmlStreamEntityDeclaration’)
                 cptr = new ::QXmlStreamEntityDeclaration(*cppArg0);


But it looks liek some error inside the code...

Sorry qingfeng.xia we are hijacking your thread!