Improve gauge grid layout

This commit is contained in:
2026-07-07 23:00:49 +01:00
parent ceba71927d
commit 44403bea2b
6 changed files with 260 additions and 10 deletions

View File

@@ -37,12 +37,16 @@ dpg.destroy_context()
```python
with dpg.window(label="Engine"):
with dpgg.gauge_panel(label="Powertrain", width=-1, height=260):
with dpgg.gauge_grid(columns=3):
with dpgg.gauge_grid(columns=3, min_column_width=180):
dpgg.analog_gauge(tag="rpm", label="RPM", max_value=8000, redline_start=6500)
dpgg.bar_gauge(tag="boost", label="Boost", max_value=30, unit="psi")
dpgg.status_light(tag="ecu", label="ECU", state=True)
```
`gauge_grid` is a wrapping, table-backed layout. `columns` is a maximum; if the parent is too
narrow for `columns * min_column_width`, the grid uses fewer columns and continues on the next row
instead of creating a horizontal scrollbar. Gauges with `width=0` or `width=-1` fill their grid cell.
Gauges also accept Dear PyGui's usual `parent` argument for adding a gauge to an
existing container after that container has already been created: