PyVista PyQt Interface

PyVista has an interface for placing plots in PyQt5 that extends the functionality of the QVTKRenderWindowInteractor class. The pyvista.QtInteractor class allows you to have the same functionality of the Plotter class within a PyQt5 application. This simplifies adding meshes, updating, and controlling them when using PyQt5.

Example PyQt5 PyVista QtInteractor

The following example shows how to create a simple application that adds a sphere to an empty plotting window.

import sys

from PyQt5 import Qt
import numpy as np

import pyvista as pv

class MainWindow(Qt.QMainWindow):

    def __init__(self, parent=None, show=True):
        Qt.QMainWindow.__init__(self, parent)

        # create the frame
        self.frame = Qt.QFrame()
        vlayout = Qt.QVBoxLayout()

        # add the pyvista interactor object
        self.plotter = pv.QtInteractor(self.frame)


        # simple menu to demo functions
        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('File')
        exitButton = Qt.QAction('Exit', self)

        # allow adding a sphere
        meshMenu = mainMenu.addMenu('Mesh')
        self.add_sphere_action = Qt.QAction('Add Sphere', self)

        if show:

    def add_sphere(self):
        """ add a sphere to the pyqt frame """
        sphere = pv.Sphere()

if __name__ == '__main__':
    app = Qt.QApplication(sys.argv)
    window = MainWindow()

PyQt5 pyvista QtInteractor

Background Plotting

Normal PyVista plotting windows exhibit blocking behavior, but it is possible to plot in the background and update the plotter in real-time using the BackgroundPlotter object. This requires PyQt5, but otherwise appears and functions like a normal PyVista Plotter instance. For example:

import pyvista as pv

sphere = pv.Sphere()

plotter = pv.BackgroundPlotter()

# can now operate on the sphere and have it updated in the background
sphere.points *= 0.5




Return render window size.


add_callback(func[, interval, count])

Add a function that can update the scene in the background.


Close the plotter.


Reset all of the key press events to their defaults.


Open scale axes dialog.


Update the app icon if the user is not trying to resize the window.

class pyvista.BackgroundPlotter(show=True, app=None, window_size=None, off_screen=None, allow_quit_keypress=True, **kwargs)

Bases: pyvista.plotting.qt_plotting.QtInteractor

Qt interactive plotter.

Background plotter for pyvista that allows you to maintain an interactive plotting window without blocking the main python thread.

  • show (bool, optional) – Show the plotting window. If False, show this window by running show()

  • app (PyQt5.QtWidgets.QApplication, optional) – Creates a QApplication if left as None.

  • window_size (list, optional) – Window size in pixels. Defaults to [1024, 768]

  • off_screen (bool, optional) – Renders off screen when True. Useful for automated screenshots or debug testing.

  • allow_quit_keypress (bool, optional) – Allow user to exit by pressing "q".

  • title (str, optional) – Title of plotting window.

  • multi_samples (int, optional) – The number of multi-samples used to mitigate aliasing. 4 is a good default but 8 will have better results with a potential impact on performance.

  • line_smoothing (bool, optional) – If True, enable line smothing

  • point_smoothing (bool, optional) – If True, enable point smothing

  • polygon_smoothing (bool, optional) – If True, enable polygon smothing

  • auto_update (float, bool, optional) – Automatic update rate in seconds. Useful for automatically updating the render window when actors are change without being automatically Modified. If set to True, update rate will be 1 second.


>>> import pyvista as pv
>>> plotter = pv.BackgroundPlotter()
>>> actor = plotter.add_mesh(pv.Sphere())
add_callback(func, interval=1000, count=None)

Add a function that can update the scene in the background.

  • func (callable) – Function to be called with no arguments.

  • interval (int) – Time interval between calls to func in milliseconds.

  • count (int, optional) – Number of times func will be called. If None, func will be called until the main window is closed.


Close the plotter.

This function closes the window which in turn will close the plotter through signal_close.


Reset all of the key press events to their defaults.

Handles closing configuration for q-key.


Open scale axes dialog.


Update the app icon if the user is not trying to resize the window.

property window_size

Return render window size.