Comments (12)
Hello @RubendeBruin and thanks for your interest pyside2
integration.
We've been in contact with another company that's tried to do the same thing with some success and I'd like to post part of the details of the implementation here:
VTK needs to be fiddled as mentioned in https://discourse.vtk.org/t/vtk-8-2-0-come-and-get-it/174/9
The PySide2 support is provided by two Python files:
https://gitlab.kitware.com/vtk/vtk/tree/master/Wrapping/Python/vtkmodules/qt 19
You can copy those files into an existing VTK 8.1.2 installation in order to get PySide2 support. If that isn’t possible, you can copy QVTKRenderWindowInteractor.py into your own project and import it directly.
Then PySide2 needs to be included in the PyVista modules
In the init.py of the qt module
# PyQtImpl can be set by the user
PyQtImpl = "PySide2"
# Has an implementation has been imported yet?
if PyQtImpl is None:
for impl in ["PyQt5", "PySide2", "PyQt4", "PySide"]:
if impl in sys.modules:
PyQtImpl = impl
break
In `qt_plotting.py`
```python
if vtk.qt.PyQtImpl == 'PySide2':
try:
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from PySide2.QtCore import (Signal as pyqtSignal, Slot as pyqtSlot, QObject, QTimer)
from PySide2 import QtGui
from PySide2 import QtCore
from PySide2.QtWidgets import (QMenuBar, QVBoxLayout, QHBoxLayout, QDoubleSpinBox,
QFrame, QMainWindow, QSlider, QAction,
QSpinBox, QHBoxLayout, QDialog,
QFormLayout, QGroupBox, QFileDialog)
has_pyqt = True
except ImportError: # pragma: no cover
pass
Considering that BackgroundPlotter
uses pyqt extensively and load the plotter on init, we'd have to rework the class to make it work with both pyqt
and pyside
. I personally never liked (and always through it was a bit of a hack) to load a module and then have to set a value in the module and then proceed with an import. Rather, I'd prefer to have either BackgroudPlotter(backend='pyside')
or PySideBackgroundPlotter
(name needs work).
@GuillaumeFavelier, your throughs? Considering that this is continuing to get more complex, we might consider implementing this alongside pyvista/pyvista#614.
from pyvistaqt.
Hi @akaszynski ,
the code that you pasted looks a lot like the way matplotlib is handeling the compatibility: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/qt_compat.py
So I guess it is a good way of doing it.
On the other hand, since vtk is a hard requirement, it may also make sense to adopt their way of doing it. Adopting the vtk has the benefit that you are sure that any vtk module that is used is using the same implementation.
from pyvistaqt.
Also related: pyvista/pyvista-support#44
from pyvistaqt.
from pyvista/pyvista#44: "It'd be nice if we could set up PyVista to work with both. PyQt5 and PySide2 - I'll think about how we could make this work"
--> Propose to do the same as vtk does:
import vtkmodules.qt
vtkmodules.qt.PyQtImpl = 'PySide2'
so we can check the value of vtkmodules.qt.PyQtImpl and base on that either import PyQt or Pyside.
from pyvistaqt.
That would be awesome to have support for PySide2! I think we could use vtkmodules
directly like @RubendeBruin described then import depending on the implementation?
@akaszynski I agree with you BackgroundPlotter(backend='pyside')
looks cleaner
Considering that this is continuing to get more complex, we might consider implementing this alongside pyvista/pyvista#614.
Sounds like a plan. Maybe we could draft a roadmap for it actually.
from pyvistaqt.
Spoke with the guys who make PyQt
at Riverbank, and it seems that if you're developing commercial software that imports PyQt
, you'll have to make your code subject to GPL. We can include references to PyQt
in our source, but as soon as we start importing PyQt
, the MIT license not longer applies.
We're going to have to make a switch over to pyside
at some point in the near future so people can develop commercial applications that use pyvista
without resorting to GPL licensing.
from pyvistaqt.
Well, let me know if you need some help. Very recently did this for two other applications and it is basically just replacing the imports than changing QtCore.pyqtSignal and QtCore.pyqtSlot to PySide2 it’s QtCore.Signal and QtCore.Slot.
And then forcing matplotlib and vtk to use pyside as backend.
from pyvistaqt.
Spoke with the guys who make
PyQt
at Riverbank, and it seems that if you're developing commercial software that importsPyQt
, you'll have to make your code subject to LGPL. We can include references toPyQt
in our source, but as soon as we start importingPyQt
, the MIT license not longer applies.
Correction to that (laymans explanations, obviously not court material): PzQt is GPL, not LGPL - and that's the problem as it is much more restrictive. Pyside on the other hand is LGPL, which only applies to Pyside itsel, not to the code importing it.
from pyvistaqt.
Updated my comment. Thanks @imsodin.
from pyvistaqt.
And what do you think about qtpy?
from pyvistaqt.
qtpy
looks like a good option
from pyvistaqt.
Closing by #61
from pyvistaqt.
Related Issues (20)
- only one of the subplots work on 4k monitor
- Online documentation not up to date HOT 1
- Lingering references prevent garbage collection
- Segmentation fault on Mac with PyQt5 HOT 2
- Race condition: BackgroundPlotter has no attribute named image HOT 3
- Running pyvistaqt project in Github Action HOT 2
- Inconsistent plotting results with PyVistaQT versus Jupyter (Trame) backends HOT 3
- Issue using pyvistaqt QtInteractor on Windows 10
- MAINT: Deploy docs HOT 7
- solicitud para agregar característica, para guardar los modelos en formato obj
- Stage release for PyVista 0.40 HOT 3
- Update GC testing fixture
- MAINT: Remove Azure
- Make the canvas background transparent HOT 1
- X Error of failed request: BadWindow (invalid Window parameter) HOT 3
- Border glitch during resize HOT 6
- macOS `pvqt.BackgroundPlotter` never opens window HOT 1
- DOC: MultiPlotter vs BackgroundPlotter
- no mouse interactivity with BackgroundPlotter HOT 1
- Consider adding `.git_archival.txt` to include version number in git archive
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvistaqt.