Viewer FPS label

Display a 3D volume and the fps label.

Tags: experimental

viewer fps label
/home/melissa/projects/napari/examples/viewer_fps_label.py:22: FutureWarning: Public access to Window.qt_viewer is deprecated and will be removed in
v0.5.0. It is considered an "implementation detail" of the napari
application, not part of the napari viewer model. If your use case
requires access to qt_viewer, please open an issue to discuss.
  viewer.window.qt_viewer.canvas.measure_fps(callback=update_fps)

import numpy as np

import napari


def update_fps(fps):
    """Update fps."""
    viewer.text_overlay.text = f"{fps:1.1f} FPS"


viewer = napari.Viewer()
viewer.add_image(np.random.random((5, 5, 5)), colormap='red', opacity=0.8)
viewer.text_overlay.visible = True
viewer.window.qt_viewer.canvas.measure_fps(callback=update_fps)

if __name__ == '__main__':
    napari.run()

Gallery generated by Sphinx-Gallery