Release 1.1.2

This commit is contained in:
2026-07-08 11:35:40 +01:00
parent 5b1826d9c3
commit c95ed3a239
9 changed files with 188 additions and 9 deletions

View File

@@ -14,6 +14,17 @@ def _children(item: int | str) -> dict[int, list[int | str]]:
return cast(dict[int, list[int | str]], dpg.get_item_children(item))
def _occupied_cell_counts(table: int | str) -> list[int]:
counts: list[int] = []
for row in _children(table)[1]:
occupied = 0
for cell in _children(row)[1]:
if any(dpg.does_item_exist(child) for child in _children(cell)[1]):
occupied += 1
counts.append(occupied)
return counts
@pytest.fixture
def dpg_context() -> Generator[None]:
clear_registry()
@@ -212,3 +223,44 @@ def test_auto_grid_reflows_existing_gauges_when_panel_narrows(dpg_context: None)
for index in range(6):
cell = cast(int | str, dpg.get_item_parent(f"resize_metric_{index}"))
assert dpg.get_item_type(cell) == "mvAppItemType::mvTableCell"
def test_grid_compacts_after_runtime_gauge_delete(dpg_context: None) -> None:
from dpg_gauges.widget import _cleanup_grid_now
with dpg.window(label="Reconnect", width=800):
dpgg.gauge_grid(tag="connector_grid", columns=3, min_column_width=1)
for cycle in range(3):
tags = [f"connector_{cycle}_{index}" for index in range(3)]
for index, tag in enumerate(tags):
dpgg.digital_gauge(tag=tag, parent="connector_grid", value=index, height=60)
children = _children("connector_grid")
assert [len(_children(row)[1]) for row in children[1]] == [3]
assert _occupied_cell_counts("connector_grid") == [3]
for tag in tags:
dpgg.delete_gauge(tag)
_cleanup_grid_now("connector_grid")
children = _children("connector_grid")
assert children[1] == []
def test_grid_reuses_deleted_cell_before_appending(dpg_context: None) -> None:
with dpg.window(label="Partial", width=800):
dpgg.gauge_grid(tag="partial_grid", columns=3, min_column_width=1)
for index in range(3):
dpgg.digital_gauge(tag=f"partial_{index}", parent="partial_grid", value=index, height=60)
dpgg.delete_gauge("partial_1")
assert _occupied_cell_counts("partial_grid") == [2]
dpgg.digital_gauge(tag="partial_new", parent="partial_grid", value=99, height=60)
children = _children("partial_grid")
assert [len(_children(row)[1]) for row in children[1]] == [3]
assert _occupied_cell_counts("partial_grid") == [3]