[vtkusers] switching from PyQt4 to PySide question

Justin Weber onlyjus at gmail.com
Sat Dec 10 22:54:16 EST 2016


FYI, you can use QtPy to support PyQt4/PyQt5/Pyside
https://github.com/spyder-ide/qtpy


On Dec 10, 2016 10:49 PM, "David Gobbi" <david.gobbi at gmail.com> wrote:

> Hi Chen,
>
> There should be no need to recompile VTK in order to use PySide.  The only
> important file for using VTK with PySide (or with PyQt4 or PyQt5)
> is QVTKRenderWindowInteractor.py.  Also, it's best to import it from
> vtk.qt, not from vtk.qt4 (which is obsolete).
>
> My recommendation is to grab the latest version of this file from the VTK
> master branch:
> https://gitlab.kitware.com/vtk/vtk/raw/master/Wrapping/Python/vtk/qt/
> QVTKRenderWindowInteractor.py
>
>  - David
>
> On Sat, Dec 10, 2016 at 8:06 PM, hchen <hjchen.work at gmail.com> wrote:
>
>> Hello,
>>
>> I'm trying to figure out how to switch from PyQt4 to PySide for my VTK
>> program.  From what I heard, it should be straight forward. But, when I
>> took
>> the example:
>>     http://www.vtk.org/Wiki/VTK/Examples/Python/Widgets/EmbedPyQt
>> and replaced:
>>     from PyQt4 import QtCore, QtGui
>> by:
>>     from PySide import QtCore, QtGui
>> I got this error:
>>     self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
>>     File
>> "/usr/local/lib/python3.5/site-packages/vtk/qt/QVTKRenderWin
>> dowInteractor.py",
>> line 204, in __init__
>>     QWidget.__init__(self, parent, wflags|Qt.MSWindowsOwnDC)
>>     TypeError: QWidget(QWidget parent=None, Qt.WindowFlags flags=0):
>> argument 1 has unexpected type 'PySide.QtGui.QFrame'
>>
>> Can anyone please points out why is the error and what's involved in
>> making
>> the switch? Do I need to remove PyQt and recompile VTK?  And, I am on
>> Ubuntu
>> 16.04, with VTK 7.0, Python 3.5, QT4.8, PyQt 4.11.4, PySide 1.2.2,  but in
>> the error, there is Qt.MSWindowsOwnDC, looks like it's for Windows?
>>
>> Thanks a lot in advance!
>>
>> Chen
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161210/f24f3415/attachment.html>


More information about the vtkusers mailing list