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!
Post Reply
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: PySide migration

Post by yorik »

For the wiki, I'm not sure what todo... There is quite a lot, but most of the occurences are links to the PyQt page. Not sure what happens if we rename that page to PySide, but it might be the best solution...
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: PySide migration

Post by NormandC »

ulrich1a wrote:
wmayer wrote:Have you installed the dev packages for shiboken and pyside?
libshiboken-dev was missing.
I called then "make clean" But even after install this, I got the same error.
What versions of pyside and shiboken are needed?
I have:
libshiboken-dev_1.1.1-1_i386.deb
libpyside-dev_1.1.1-3

Ulrich
I have both libpyside-dev and libshiboken-dev installed. I'm getting the same error with the latest source code. I get that window each time I switch to the Arch or Draft workbench.
FC_Draft_wb_failure.png
FC_Draft_wb_failure.png (16.75 KiB) Viewed 3196 times
BTW the Daily Builds PPA package has the same problem. I am not sure we can correct this on Ubuntu. For example, python-matplotlib depends on python-qt4. Isn't the Ship module built on matplotlib? And the Shaft Wizard? python-pivy, which is required by Draft and Arch, depends on python-qt4-gl, which itself requires of course python-qt4.

So it looks to me like we cannot expunge pyqt completely from FreeCAD's dependencies on Ubuntu. Please tell me if I'm wrong. :|
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: PySide migration

Post by NormandC »

Yeah, in both versions (compiled from source and Daily Build) Draft is completely broken. :(
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: PySide migration

Post by ulrich1a »

normandc wrote:BTW the Daily Builds PPA package has the same problem. I am not sure we can correct this on Ubuntu.
I solved the problem for me with Debian in the meantime. I had to completly delete all the contents in the Build folder and than starting from scratch with "cmake-gui .." in this folder. This went smoother than I thought. In the past I had to do several manual corrections to the cmakecache.txt file.
Only calling "cmake ." gave me all the time problems. But with the restart from scratch, I could call the Draft workbench.


I have Problems on Windows 7 32 bit with the same approach. The executable file is now named FreeCADD.exe. The Draft-Workbench gives me: local variable 'translate' referenced before assignment
This is not the case at Debian.
OS: Windows 7
Platform: 32-bit
Version: 0.14.2982 (Git)
Branch: master
Hash: 4c6bd17dc2c53e05ec7f3c1d612722c5af36d2c0
Python version: 2.6.2
Qt version: 4.5.2
Coin version: 3.1.0
SoQt version: 1.4.1

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

Re: PySide migration

Post by wmayer »

- Plot and Ship must be switched (see with sanguinario joe)
- src/WindowsInstaller/LibPack.wxs contains references to PyQt4, don't know what to do there
- PartDesign scripts
- Update the wiki (do that with care)
- Material resource file
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

So it looks to me like we cannot expunge pyqt completely from FreeCAD's dependencies on Ubuntu. Please tell me if I'm wrong.
We won't be able to remove this dependency but this isn't a big problem. We only have to make sure not to use PyQt stuff inside FreeCAD. And what 3rd party Python libraries do doesn't affect FreeCAD as long as we don't try to extract the internal C++ classes because this is technically the big difference between PySide and PyQt.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: PySide migration

Post by jmaustpc »

yorik wrote:For the wiki, I'm not sure what todo... There is quite a lot, but most of the occurences are links to the PyQt page. Not sure what happens if we rename that page to PySide, but it might be the best solution...
Aren't we going to now be left with the situation that everyone using 0.13 "stable" will still be using PyQT? If so the wiki needs to talk about both for the time being until we "officially dump" 0.13. Also any script/Python code using these will have to have two version written now, if one wants it to work on both the "stable" and "dev" versions of FreeCAD. There is now a similar problem for "BOLTS".

I am starting to wonder if this might be a good enough reason to "release" a new "stable" version of FreeCAD that uses PySide, and includes all work to date from master, and possibly (or possibly not) some or all of the Assembly stuff?

I would think this would make life easier for BOLTS because then they could be reasonably justified in just dropping support for FreeCADs older than 0.14.

I am always keen to release "new official" versions as often as possible. :)

Jim
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: PySide migration

Post by jriegel »

Furthermore, Plot depends on matplotlib, which has a PyQt binding to generate plot canvas. So I left PyQt and PySide in the LibPack 8.2. I also added NumPy and Matplotlib (release only) to the LibPack. Also added the CalculiX FEM solver (ccx.exe) to the LibPack.
Stop whining - start coding!
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: PySide migration

Post by jreinhardt »

I started to make BOLTS usable with both PySide and PyQt, but now I hit a problem that I do not understand. I get the following error:

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "./BOLTS/__init__.py", line 42, in <module>
    mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, widget)
TypeError: arguments did not match any overloaded call:
  QMainWindow.addDockWidget(Qt.DockWidgetArea, QDockWidget): argument 1 has unexpected type 'PySide.QtCore.Qt.DockWidgetArea'
  QMainWindow.addDockWidget(Qt.DockWidgetArea, QDockWidget, Qt.Orientation): argument 1 has unexpected type 'PySide.QtCore.Qt.DockWidgetArea'
>>> 
It is triggered when I try to add the part selector widget to the main window. The code that does this is a refined version of a snippet from here ( and the relevant parts looks like this:

Code: Select all

        mw = getMainWindow()
        mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, widget)
and

Code: Select all

def getMainWindow():
        "returns the main window"
        # using QtGui.qApp.activeWindow() isn't very reliable because if another
        # widget than the mainwindow is active (e.g. a dialog) the wrong widget is
        # returned
        toplevel = QtGui.qApp.topLevelWidgets()
        for i in toplevel:
                if i.metaObject().className() == "Gui::MainWindow":
                        return i
        raise Exception("No main window found")
While I tried to find out what is happening, I realised that either there is a lot of magic going on in the background or I am completely lost:

Code: Select all

import PySide
toplevel = PySide.QtGui.qApp.topLevelWidgets()
for i in toplevel:
    if i.metaObject().className() == "Gui::MainWindow":
        mw = i
results in mw having type <PySide.QtGui.QWidget object at 0x2ab09e0>, which does not provide addDockWidget, but from the stacktrace it seems that the call succeeded but a exception was raised in addDockWidget.

On the other hand

Code: Select all

import PyQt4
toplevel = PyQt4.QtGui.qApp.topLevelWidgets()
for i in toplevel:
    if i.metaObject().className() == "Gui::MainWindow":
        mw = i
results in a mw with type <PyQt4.QtGui.QMainWindow object at 0x2ab2290>.

I appreciate any hints about what is going on and how to reliably add a widget.

OS: Ubuntu 13.04
Platform: 64-bit
Version: 0.14.2982 (Git)
Branch: master
Hash: 4c6bd17dc2c53e05ec7f3c1d612722c5af36d2c0
Python version: 2.7.4
Qt version: 4.8.4
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.5.0
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 »

I started to make BOLTS usable with both PySide and PyQt, but now I hit a problem that I do not understand. I get the following error:
That's because PySide doesn't know that in C++ "MainWindow" inherits from QMainWindow and thus only handles it as QWidget. Instead of writing "def getMainWindow(): ..." you can use:

Code: Select all

mw = FreeCADGui.getMainWindow()
then everything is fine.
Post Reply