bec_widgets.utils.fps_counter#
This module provides a utility class for counting and reporting frames per second (FPS) in a PyQtGraph application.
- Classes:
FPSCounter: A class that monitors the paint events of a ViewBox to calculate and emit FPS values.
- Usage:
The FPSCounter class can be used to monitor the rendering performance of a ViewBox in a PyQtGraph application. It connects to the ViewBox’s paint event and calculates the FPS over a specified interval, emitting the FPS value at regular intervals.
Example
from qtpy import QtWidgets, QtCore import pyqtgraph as pg from fps_counter import FPSCounter
app = pg.mkQApp(“FPS Counter Example”) win = pg.GraphicsLayoutWidget() win.show()
vb = pg.ViewBox() plot_item = pg.PlotItem(viewBox=vb) win.addItem(plot_item)
fps_counter = FPSCounter(vb) fps_counter.sigFpsUpdate.connect(lambda fps: print(f”FPS: {fps:.2f}”))
sys.exit(app.exec_())
Classes#
A utility class for counting and reporting frames per second (FPS). |
Module Contents#
- class FPSCounter(view_box)#
Bases:
qtpy.QtCore.QObjectA utility class for counting and reporting frames per second (FPS).
This class connects to a ViewBox’s paint event to count the number of frames rendered and calculates the FPS over a specified interval. It emits a signal with the FPS value at regular intervals.
- sigFpsUpdate#
Signal emitted with the FPS value.
- Type:
QtCore.Signal
- view_box#
The ViewBox instance to monitor.
- Type:
pg.ViewBox
- calculate_fps()#
Calculate the frames per second (FPS) based on the number of frames
- cleanup()#
Clean up the FPS counter by stopping the timer and disconnecting the signal.
- increment_count()#
Increment the frame count when the ViewBox is painted.
- count = 0#
- last_update#
- sigFpsUpdate#
- timer#
- view_box#