step 4: add digital bar level and status gauges

This commit is contained in:
2026-07-02 14:35:13 +02:00
parent 41e44a23bc
commit d638c512e9
11 changed files with 516 additions and 21 deletions

33
examples/basic_bar.py Normal file
View File

@@ -0,0 +1,33 @@
# pyright: reportGeneralTypeIssues=false
import dearpygui.dearpygui as dpg
import dpg_gauges as dpgg
def main() -> None:
dpg.create_context()
try:
with dpg.window(label="Bar Gauge", width=360, height=180):
dpgg.bar_gauge(
tag="boost",
label="Boost",
value=18.5,
min_value=0,
max_value=30,
unit="psi",
precision=1,
width=300,
height=100,
)
dpg.create_viewport(title="dpg-gauges bar", width=400, height=220)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
finally:
dpg.destroy_context()
if __name__ == "__main__":
main()

30
examples/basic_level.py Normal file
View File

@@ -0,0 +1,30 @@
# pyright: reportGeneralTypeIssues=false
import dearpygui.dearpygui as dpg
import dpg_gauges as dpgg
def main() -> None:
dpg.create_context()
try:
with dpg.window(label="Level Gauge", width=260, height=320):
dpgg.level_gauge(
tag="fuel",
label="Fuel",
value=68,
unit="%",
width=180,
height=240,
)
dpg.create_viewport(title="dpg-gauges level", width=300, height=360)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
finally:
dpg.destroy_context()
if __name__ == "__main__":
main()

35
examples/basic_status.py Normal file
View File

@@ -0,0 +1,35 @@
# pyright: reportGeneralTypeIssues=false
import dearpygui.dearpygui as dpg
import dpg_gauges as dpgg
def main() -> None:
dpg.create_context()
try:
states = {
"ok": dpgg.StatusState((0, 220, 120, 255), "OK"),
"warn": dpgg.StatusState((255, 190, 0, 255), "WARN"),
"fault": dpgg.StatusState((255, 45, 45, 255), "FAULT"),
}
with dpg.window(label="Status Light", width=300, height=160):
dpgg.status_light(
tag="ecu",
label="ECU",
state="ok",
states=states,
width=240,
height=80,
)
dpg.create_viewport(title="dpg-gauges status", width=340, height=200)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
finally:
dpg.destroy_context()
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,37 @@
# pyright: reportGeneralTypeIssues=false
import dearpygui.dearpygui as dpg
import dpg_gauges as dpgg
def main() -> None:
dpg.create_context()
try:
thresholds = [
dpgg.ThresholdBand(0, 30, (60, 180, 90, 150), "normal"),
dpgg.ThresholdBand(70, 100, (255, 80, 45, 150), "hot"),
]
markers = [dpgg.GaugeMarker(85, (255, 255, 255, 255), "limit", 3)]
with dpg.window(label="Thresholds and Markers", width=420, height=220):
dpgg.bar_gauge(
tag="coolant",
label="Coolant",
value=76,
unit="C",
width=340,
height=100,
thresholds=thresholds,
markers=markers,
)
dpg.create_viewport(title="dpg-gauges thresholds", width=460, height=260)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
finally:
dpg.destroy_context()
if __name__ == "__main__":
main()