pyvistaqt
pyvistaqt copied to clipboard
no mouse interactivity with BackgroundPlotter
Describe the bug, what's wrong, and what you expected.
Not sure whether this is a bug or intended behavior. I thought that BackgroundPlotter
was supposed to allow mouse interaction while other code is running on the main thread. However, running the example below, the window opens and the sphere displays, but the window is unresponsive to mouse events - e.g., trying to rotate or zoom the camera view. System information and package versions are noted below.
Steps to reproduce the bug.
import pyvista as pv
from pyvistaqt import BackgroundPlotter
plotter = BackgroundPlotter()
plotter.add_mesh(pv.Sphere())
import time
while True:
time.sleep(1)
System Information
Date: Mon Oct 30 08:31:49 2023 EDT
OS : Linux
CPU(s) : 12
Machine : x86_64
Architecture : 64bit
Environment : Python
GPU Vendor : Mesa
GPU Renderer : llvmpipe (LLVM 15.0.7, 256 bits)
GPU Version : 4.5 (Core Profile) Mesa 23.0.4-0ubuntu1~22.04.1
MathText Support : False
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
pyvista : 0.41.1
vtk : 9.2.6
numpy : 1.24.3
matplotlib : 3.7.1
scooby : 0.7.2
pooch : v1.7.0
imageio : 2.31.1
pyvistaqt : 0.11.0
PyQt5 : 5.15.10
IPython : 8.13.2
scipy : 1.11.1
--------------------------------------------------------------------------------
Screenshots
No response
To enable interaction with the BackgroundPlotter
while running other operations, you should integrate it within a Qt application event loop. Here's how you can modify your code:
import sys
import pyvista as pv
from pyvistaqt import BackgroundPlotter
from PyQt5.QtWidgets import QApplication
if __name__ == '__main__':
app = QApplication(sys.argv)
gui = BackgroundPlotter()
gui.add_mesh(pv.Sphere())
app.exec_()
When app.exec_()
is called, it starts the application's event loop, allowing for UI interaction.