Files
sunnypilot/system/ui/lib/button.py
T
Dean Lee ce7ff5c0e6 ui: Initial UI rewrite using pyray (spinner and text window) (#34583)
* pyray init version

* remove c++ code

* cleanup

* restruct the directory layout

* improve GuiApplication

* smooth out the texture after resize

* use atexit to close app

* rename FontSize->FontWeight

* make files executable

* use Inter Regular for FrontWeight.NORMAL

* set FLAG_VSYNC_HINT to avoid tearing while scrolling

* smoother scrolling

* mange textures in gui_app
2025-02-15 12:44:20 -08:00

15 lines
500 B
Python

import pyray as rl
from openpilot.system.ui.lib.utils import GuiStyleContext
BUTTON_DEFAULT_BG_COLOR = rl.Color(51, 51, 51, 255)
def gui_button(rect, text, bg_color=BUTTON_DEFAULT_BG_COLOR):
styles = [
(rl.GuiControl.DEFAULT, rl.GuiDefaultProperty.TEXT_ALIGNMENT_VERTICAL, rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE),
(rl.GuiControl.DEFAULT, rl.GuiControlProperty.BASE_COLOR_NORMAL, rl.color_to_int(bg_color))
]
with GuiStyleContext(styles):
return rl.gui_button(rect, text)