step 7: harden docs and prepare beta
This commit is contained in:
@@ -35,6 +35,8 @@ from .types import (
|
||||
ThresholdBand,
|
||||
)
|
||||
|
||||
__version__ = "0.1.0b1"
|
||||
|
||||
__all__ = [
|
||||
"configure",
|
||||
"GaugeTheme",
|
||||
@@ -67,8 +69,10 @@ __all__ = [
|
||||
"set_show",
|
||||
"delete_gauge",
|
||||
"get_gauge_debug_state",
|
||||
"__version__",
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Print a short message for the package console script."""
|
||||
print("dpg-gauges is a library package; import dpg_gauges to use it.")
|
||||
|
||||
@@ -20,6 +20,7 @@ from .types import GaugeMarker, GaugeValue, Tag, ThresholdBand
|
||||
|
||||
|
||||
def configure(**config: Any) -> None:
|
||||
"""Configure package-wide defaults for subsequently created gauges."""
|
||||
configure_gauges(**config)
|
||||
|
||||
|
||||
@@ -38,34 +39,42 @@ gauge_grid = _widget.gauge_grid
|
||||
|
||||
|
||||
def set_value(tag: Tag, value: GaugeValue) -> None:
|
||||
"""Set a gauge target value from the Dear PyGui GUI thread."""
|
||||
set_runtime_value(tag, value)
|
||||
|
||||
|
||||
def get_value(tag: Tag) -> GaugeValue:
|
||||
"""Return the latest raw target value assigned to a gauge."""
|
||||
return get_runtime_value(tag)
|
||||
|
||||
|
||||
def update_gauge(tag: Tag, **config: Any) -> None:
|
||||
"""Update a gauge value and/or configuration fields."""
|
||||
update_runtime_gauge(tag, **config)
|
||||
|
||||
|
||||
def configure_gauge(tag: Tag, **config: Any) -> None:
|
||||
"""Update configuration fields for an existing gauge."""
|
||||
update_runtime_gauge(tag, **config)
|
||||
|
||||
|
||||
def set_thresholds(tag: Tag, thresholds: list[ThresholdBand] | tuple[ThresholdBand, ...]) -> None:
|
||||
"""Replace the visual threshold bands for an existing gauge."""
|
||||
set_runtime_thresholds(tag, thresholds)
|
||||
|
||||
|
||||
def set_markers(tag: Tag, markers: list[GaugeMarker] | tuple[GaugeMarker, ...]) -> None:
|
||||
"""Replace the visual markers for an existing gauge."""
|
||||
set_runtime_markers(tag, markers)
|
||||
|
||||
|
||||
def set_show(tag: Tag, show: bool) -> None:
|
||||
"""Show or hide an existing gauge."""
|
||||
set_runtime_show(tag, show)
|
||||
|
||||
|
||||
def delete_gauge(tag: Tag) -> None:
|
||||
"""Delete an existing gauge and its Dear PyGui shell when attached."""
|
||||
delete_runtime_gauge(tag)
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from .types import Tag
|
||||
|
||||
|
||||
def get_gauge_debug_state(tag: Tag) -> dict[str, Any]:
|
||||
"""Return renderer and state diagnostics for an existing gauge."""
|
||||
state = get_gauge_state(tag)
|
||||
debug = {
|
||||
"tag": state.tag,
|
||||
|
||||
@@ -139,6 +139,7 @@ def create_gauge_context(gauge_type: str, config: ConfigT) -> GaugeContext[Confi
|
||||
|
||||
|
||||
def gauge_panel(**config: Any) -> LayoutContext:
|
||||
"""Create a lightweight child-window container for related gauges."""
|
||||
if not _dpg_context_active:
|
||||
return LayoutContext(None)
|
||||
tag = config.pop("tag", 0)
|
||||
@@ -160,6 +161,7 @@ def gauge_panel(**config: Any) -> LayoutContext:
|
||||
|
||||
|
||||
def gauge_grid(**config: Any) -> LayoutContext:
|
||||
"""Create a lightweight horizontal gauge layout container."""
|
||||
if not _dpg_context_active:
|
||||
return LayoutContext(None)
|
||||
columns = max(int(config.pop("columns", 1)), 1)
|
||||
@@ -175,42 +177,52 @@ def gauge_grid(**config: Any) -> LayoutContext:
|
||||
|
||||
|
||||
def analog_gauge(**config: Any) -> GaugeContext[AnalogGaugeConfig]:
|
||||
"""Create an analog dial gauge with ticks, needle, thresholds, and markers."""
|
||||
return create_gauge_context("analog", AnalogGaugeConfig(**config))
|
||||
|
||||
|
||||
def digital_gauge(**config: Any) -> GaugeContext[DigitalGaugeConfig]:
|
||||
"""Create a large numeric readout gauge."""
|
||||
return create_gauge_context("digital", DigitalGaugeConfig(**config))
|
||||
|
||||
|
||||
def bar_gauge(**config: Any) -> GaugeContext[BarGaugeConfig]:
|
||||
"""Create a horizontal or vertical fill bar gauge."""
|
||||
return create_gauge_context("bar", BarGaugeConfig(**config))
|
||||
|
||||
|
||||
def level_gauge(**config: Any) -> GaugeContext[LevelGaugeConfig]:
|
||||
"""Create a tank or level-style vertical gauge."""
|
||||
return create_gauge_context("level", LevelGaugeConfig(**config))
|
||||
|
||||
|
||||
def status_light(**config: Any) -> GaugeContext[StatusLightConfig]:
|
||||
"""Create an LED-style status indicator gauge."""
|
||||
return create_gauge_context("status_light", StatusLightConfig(**config))
|
||||
|
||||
|
||||
def segmented_gauge(**config: Any) -> GaugeContext[SegmentedGaugeConfig]:
|
||||
"""Create a segmented strip gauge for shift-light or cell-style displays."""
|
||||
return create_gauge_context("segmented", SegmentedGaugeConfig(**config))
|
||||
|
||||
|
||||
def compass_gauge(**config: Any) -> GaugeContext[CompassGaugeConfig]:
|
||||
"""Create a compass gauge that wraps numeric headings to 0-360 degrees."""
|
||||
return create_gauge_context("compass", CompassGaugeConfig(**config))
|
||||
|
||||
|
||||
def thermometer_gauge(**config: Any) -> GaugeContext[ThermometerGaugeConfig]:
|
||||
"""Create a thermometer-style temperature gauge."""
|
||||
return create_gauge_context("thermometer", ThermometerGaugeConfig(**config))
|
||||
|
||||
|
||||
def battery_gauge(**config: Any) -> GaugeContext[BatteryGaugeConfig]:
|
||||
"""Create a battery-style percentage or value gauge."""
|
||||
return create_gauge_context("battery", BatteryGaugeConfig(**config))
|
||||
|
||||
|
||||
def multi_value_gauge(**config: Any) -> GaugeContext[MultiValueGaugeConfig]:
|
||||
"""Create a compact grouped key/value readout gauge."""
|
||||
return create_gauge_context("multi_value", MultiValueGaugeConfig(**config))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user