[vtkusers] switching from PyQt4 to PySide question

David Gobbi david.gobbi at gmail.com
Sat Dec 10 22:48:34 EST 2016

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:

 - 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/
> QVTKRenderWindowInteractor.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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161210/fecb150d/attachment.html>

More information about the vtkusers mailing list