Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no mouse interactivity with BackgroundPlotter #499

Open
dr-matt opened this issue Oct 30, 2023 · 1 comment
Open

no mouse interactivity with BackgroundPlotter #499

dr-matt opened this issue Oct 30, 2023 · 1 comment

Comments

@dr-matt
Copy link

dr-matt commented Oct 30, 2023

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

@dr-matt dr-matt added the bug Something isn't working label Oct 30, 2023
@akaszynski
Copy link
Member

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.

@akaszynski akaszynski removed the bug Something isn't working label Nov 4, 2023
@akaszynski akaszynski transferred this issue from pyvista/pyvista Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants