bec_widgets.utils.fps_counter ============================= .. py:module:: bec_widgets.utils.fps_counter .. autoapi-nested-parse:: 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. .. rubric:: 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 ------- .. autoapisummary:: bec_widgets.utils.fps_counter.FPSCounter Module Contents --------------- .. py:class:: FPSCounter(view_box) Bases: :py:obj:`qtpy.QtCore.QObject` A 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. .. attribute:: sigFpsUpdate Signal emitted with the FPS value. :type: QtCore.Signal .. attribute:: view_box The `ViewBox` instance to monitor. :type: pg.ViewBox .. py:method:: calculate_fps() Calculate the frames per second (FPS) based on the number of frames .. py:method:: cleanup() Clean up the FPS counter by stopping the timer and disconnecting the signal. .. py:method:: increment_count() Increment the frame count when the `ViewBox` is painted. .. py:attribute:: count :value: 0 .. py:attribute:: last_update .. py:attribute:: sigFpsUpdate .. py:attribute:: timer .. py:attribute:: view_box