fixed up gui_2.py

multi viewport works and no crashes thus far
This commit is contained in:
2026-02-23 19:33:09 -05:00
parent 1d674c3a1e
commit 75e1cf84fe
4 changed files with 188 additions and 97 deletions

View File

@@ -5,7 +5,7 @@ Theming support for manual_slop GUI — imgui-bundle port.
Replaces theme.py (DearPyGui-specific) with imgui-bundle equivalents.
Palettes are applied via imgui.get_style().set_color_() calls.
Font loading uses hello_imgui.load_font().
Scale uses imgui.get_io().font_global_scale.
Scale uses imgui.get_style().font_scale_main.
"""
from imgui_bundle import imgui, hello_imgui
@@ -238,11 +238,11 @@ def apply(palette_name: str):
def set_scale(factor: float):
"""Set the global font scale factor."""
"""Set the global font/UI scale factor."""
global _current_scale
_current_scale = factor
io = imgui.get_io()
io.font_global_scale = factor
style = imgui.get_style()
style.font_scale_main = factor
def save_to_config(config: dict):
@@ -263,6 +263,12 @@ def load_from_config(config: dict):
_current_font_size = float(t.get("font_size", 16.0))
_current_scale = float(t.get("scale", 1.0))
# Don't apply here — imgui context may not exist yet.
# Call apply_current() after imgui is initialised.
def apply_current():
"""Apply the loaded palette and scale. Call after imgui context exists."""
apply(_current_palette)
set_scale(_current_scale)