Files
sunnypilot/system/ui/lib/utils.py
Dean Lee d4d0312794 python ui: display FPS on top-left corner if DEBUG_FPS=1 (#34595)
* display FPS on top-left corner if DEBUG_FPS=1

* use generator

* use rl.draw_fps
2025-02-16 12:35:04 -08:00

19 lines
637 B
Python

import pyray as rl
class GuiStyleContext:
def __init__(self, styles: list[tuple[int, int, int]]):
"""styles is a list of tuples (control, prop, new_value)"""
self.styles = styles
self.prev_styles: list[tuple[int, int, int]] = []
def __enter__(self):
for control, prop, new_value in self.styles:
prev_value = rl.gui_get_style(control, prop)
self.prev_styles.append((control, prop, prev_value))
rl.gui_set_style(control, prop, new_value)
def __exit__(self, exc_type, exc_value, traceback):
for control, prop, prev_value in self.prev_styles:
rl.gui_set_style(control, prop, prev_value)