PySide migration

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

Is the compiling something new to pyside or was this also done behind the scenes with pyqt4?
No, PyQt4 did this already. And when looking at the source code you'll be surprised how similar it is.
I wondering if I should add pyside-tools as an apt-recommends dependency for the wheezy package that I upload.
Makes probably sense to add it.
Sanguinario_Joe
Posts: 60
Joined: Wed Jan 01, 2014 1:17 pm

Re: PySide migration

Post by Sanguinario_Joe »

I already fixed the plot module (including the matplotlib backend and the pyside pitfalls):

viewtopic.php?f=17&t=5358

See you!
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: PySide migration

Post by jreinhardt »

I tried to find the reason for the problems I have with BOLTS (see here).

I found this bug report here: https://bugreports.qt-project.org/browse/PYSIDE-31

It seems that shiboken fails to guess the best type for an instance, which later leads to problems. I also discovered this python workaround:

http://nathanhorne.com/?p=485

However, I am not sure if I can work around this problem in python. I don't think I have access to a pointer to the instance, so I can not apply the python workaround.
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

Does this work?

Code: Select all

from PySide import QtCore
from PySide.QtGui import QDockWidget as QBoltsWidget


class BoltsWidget(QBoltsWidget):
	pass

def addWidget(widget):
	mw = Gui.getMainWindow()
	mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, widget)


widget = BoltsWidget()
addWidget(widget)
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: PySide migration

Post by jreinhardt »

Thanks that helped.

I am not sure if I was sloppy with my debugging attempts or something changed in the daily builds, but it turns out, that both wmayers testcase and my original code work now.

OS: Ubuntu 13.04
Platform: 64-bit
Version: 0.14.3012 (Git)
Branch: master
Hash: ca3b87a719825ad4065b47ade7b472e1f67dd134
Python version: 2.7.4
Qt version: 4.8.4
Coin version: 3.1.3
SoQt version: 1.5.0

I had to also handle some other things, like QVariants and automatically connected slots, but I think I got it running now for both older and newer versions. I could only test on Linux though. So if you have a Windows system, with any version of FreeCAD, it would be coold if you could test whether the most current development snapshot works for you:

http://jreinhardt.github.io/BOLTS/downloads.html
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
arcol
Posts: 223
Joined: Sun Nov 10, 2013 9:02 am

Re: PySide migration

Post by arcol »

Out of curiosity, why PyQt->PySide switch was needed?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

arcol wrote:Out of curiosity, why PyQt->PySide switch was needed?
Because PyQt is under GPL and PySide under LGPL. Since FreeCAD is also aimed to be used by companies that want to link FreeCAD with proprietary code it must be 100% GPL free.

People who e.g. write Python scripts that only shows some dialogs or the like can still use PyQt if they prefer. However, a change to PySide is a must if they want to integrate their widgets in FreeCAD's task panel.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

I am having problems with an actual build of FreeCAD on Windows 7 32 bit.
Have a look here: viewtopic.php?f=3&t=5384&start=10#p43371
For me it looks like the Pivy delivered with the FreeCAD source has references towards sip, which is used for PyQt4. Similar error messages on Linux went away after a new build from scratch.
So is there Pivy on Linux automagically build against PySide?
If it is so, how can Pivy in the Libpack be upgraded to a new build?
Pivy is made with Swig. Unfortunately I have no knowledge how to make a new build of Pivy.

Ulrich
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

I think the latest pivy version still has a reference to sip/PyQt but this is a very loose dependency. And if you look at the python-pivy package you'll see that it depends on python-qt4. Which version of the Windows LibPack 32-bit do you have?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

Look here: https://bitbucket.org/Coin3D/pivy/src/8 ... at=default and search sip.
Maybe you should try:

Code: Select all

import sip
print sip.__file__
dir(sip)
What does this give?
Post Reply