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
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: PySide migration

Post by jreinhardt »

Cool, that is exactly what I need!

Is that available already in 0.13, or do I have to implement that conditionally?

Shall I update the wiki?
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: PySide migration

Post by jreinhardt »

Now I run in a similar problem, BoltsWidget is a subclass of PySide.QtGui.QDockWidget, but addDockWidget chokes on it:

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: 'PySide.QtGui.QMainWindow.addDockWidget' called with wrong argument types:
  PySide.QtGui.QMainWindow.addDockWidget(PySide.QtCore.Qt.DockWidgetArea, BoltsWidget)
Supported signatures:
  PySide.QtGui.QMainWindow.addDockWidget(PySide.QtCore.Qt.DockWidgetArea, PySide.QtGui.QDockWidget)
  PySide.QtGui.QMainWindow.addDockWidget(PySide.QtCore.Qt.DockWidgetArea, PySide.QtGui.QDockWidget, PySide.QtCore.Qt.Orientation)
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: PySide migration

Post by yorik »

You need to specify which dock area I think, for ex. QtCore.Qt.TopDockWidgetArea. You can chose between:

Qt.LeftDockWidgetArea
Qt.RightDockWidgetArea
Qt.TopDockWidgetArea
Qt.BottomDockWidgetArea
Qt.AllDockWidgetAreas
Qt.NoDockWidgetArea

http://srinikom.github.io/pyside-docs/P ... re/Qt.html

*EDIT* OOps sorry, I didn't read correctly... Stange, I did the same in DraftGui and it works...
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: PySide migration

Post by jreinhardt »

By the way, there is a reference to Qt4 left in the error message:

https://github.com/FreeCAD/FreeCAD_sf_m ... Gui.py#L38
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: PySide migration

Post by yorik »

Fixed! Thanks for notifying!
User avatar
cblt2l
Posts: 155
Joined: Sat May 15, 2010 3:59 am

Re: PySide migration

Post by cblt2l »

wmayer wrote:FYI, I have added a convenience module to FreeCAD which implements missing stuff from PyQt. There you could use the method 'loadUiType' which returned a tuple of a form class and the widget class of the ui file:

Code: Select all

from PySide import QtCore, QtGui
from FreeCADGui import PySideUic as uic

form_class, base_class = uic.loadUiType("myUiFile.ui")
formUi = form_class()
widget = base_class()
formUi.setupUi(widget)
widget.show()
When I run the above code with my Ui file I get:

Code: Select all

<type 'exceptions.ImportError'>: No module named pysideuic
I noticed that Mod/Gui/WidgetFactory.cpp line 321 is:

Code: Select all

 str << "import pysideuic\n"
Is this a typo?
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

Is this a typo?
No, it's not. What is your OS?
User avatar
cblt2l
Posts: 155
Joined: Sat May 15, 2010 3:59 am

Re: PySide migration

Post by cblt2l »

wmayer wrote:
Is this a typo?
No, it's not. What is your OS?
Debian Wheezy. Freecad revision 3013

If I run it line by line from the python terminal:

Code: Select all

>>> from PySide import QtCore, QtGui
>>> from FreeCADGui import PySideUic as uic
>>> form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Fem/MechanicalAnalysis.ui")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<string>", line 1, in <module>
ImportError: No module named pysideuic
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PySide migration

Post by wmayer »

Install the package pyside-tools which contains the ui compiler for Python code
http://packages.debian.org/wheezy/amd64 ... s/filelist
User avatar
cblt2l
Posts: 155
Joined: Sat May 15, 2010 3:59 am

Re: PySide migration

Post by cblt2l »

Ahhh ok. Is the compiling something new to pyside or was this also done behind the scenes with pyqt4? I wondering if I should add pyside-tools as an apt-recommends dependency for the wheezy package that I upload.
Post Reply