imgui_debugger 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,88 @@
1
+ """imgui_debugger — a live variable inspector for any imgui-bundle widget.
2
+
3
+ Examples
4
+ --------
5
+ Drop a debug window into an app you already have:
6
+
7
+ >>> from imgui_debugger import attach
8
+ >>> dbg = attach(my_widget, title="ROI tab") # doctest: +SKIP
9
+ >>> # each frame, inside your show_gui:
10
+ >>> dbg.render_window() # doctest: +SKIP
11
+
12
+ Inspect an object with no host app at all:
13
+
14
+ >>> from imgui_debugger import run_debugger
15
+ >>> run_debugger({"fs": 9.6, "dz": 5.0}) # doctest: +SKIP
16
+
17
+ Follow a function's own locals while it draws:
18
+
19
+ >>> def draw(self): # doctest: +SKIP
20
+ ... rows = self.build_rows()
21
+ ... self.dbg.capture()
22
+ ... self.dbg.render_window()
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ from ._assets import data_dir, default_ini_path, ensure_assets
28
+ from .debugger import Debugger, DebuggerConfig, attach, watch_all
29
+ from .edit import can_edit, edit_value
30
+ from .format import fmt_value, type_label
31
+ from .runner import run_debugger
32
+ from .scopes import (
33
+ Child,
34
+ Scope,
35
+ Watch,
36
+ children_of,
37
+ class_children,
38
+ frame_scopes,
39
+ instance_children,
40
+ object_scopes,
41
+ property_children,
42
+ runtime_scope,
43
+ )
44
+ from .search import clear_cache, matches
45
+ from .theme import Theme, to_vec4
46
+ from .tree import TreeStyle, draw_child, draw_children, draw_scope
47
+
48
+ __version__ = "0.1.0"
49
+
50
+ __all__ = [
51
+ # widget + harness
52
+ "Debugger",
53
+ "DebuggerConfig",
54
+ "attach",
55
+ "watch_all",
56
+ "run_debugger",
57
+ "ensure_assets",
58
+ "data_dir",
59
+ "default_ini_path",
60
+ # scopes
61
+ "Scope",
62
+ "Child",
63
+ "Watch",
64
+ "children_of",
65
+ "instance_children",
66
+ "property_children",
67
+ "class_children",
68
+ "object_scopes",
69
+ "frame_scopes",
70
+ "runtime_scope",
71
+ # rendering
72
+ "TreeStyle",
73
+ "draw_scope",
74
+ "draw_child",
75
+ "draw_children",
76
+ "can_edit",
77
+ "edit_value",
78
+ "fmt_value",
79
+ "type_label",
80
+ # search
81
+ "matches",
82
+ "clear_cache",
83
+ # theme
84
+ "Theme",
85
+ "to_vec4",
86
+ # meta
87
+ "__version__",
88
+ ]
@@ -0,0 +1,125 @@
1
+ """Per-user paths and icon-font resolution for the debugger.
2
+
3
+ Examples
4
+ --------
5
+ >>> from imgui_debugger._assets import data_dir, default_ini_path
6
+ >>> str(data_dir()).endswith(".imgui_debugger")
7
+ True
8
+ >>> default_ini_path().endswith("debugger.ini")
9
+ True
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import os
15
+ from pathlib import Path
16
+ from typing import Optional
17
+
18
+ _ICON_FONT = "fonts/Font_Awesome_6_Free-Solid-900.otf"
19
+
20
+
21
+ def imgui_bundle_assets_dir() -> Optional[str]:
22
+ """Path to imgui-bundle's bundled ``assets`` folder, or None.
23
+
24
+ Examples
25
+ --------
26
+ >>> from imgui_debugger._assets import imgui_bundle_assets_dir
27
+ >>> folder = imgui_bundle_assets_dir()
28
+ >>> folder is None or folder.endswith("assets")
29
+ True
30
+ """
31
+ try:
32
+ import imgui_bundle
33
+
34
+ p = Path(imgui_bundle.__file__).parent / "assets"
35
+ return str(p) if p.is_dir() else None
36
+ except Exception:
37
+ return None
38
+
39
+
40
+ def data_dir() -> Path:
41
+ """The per-user dir for everything this library writes, created on first use.
42
+
43
+ Defaults to ``~/.imgui_debugger``; override with ``IMGUI_DEBUGGER_HOME``.
44
+
45
+ Examples
46
+ --------
47
+ >>> import os
48
+ >>> os.environ["IMGUI_DEBUGGER_HOME"] = os.path.join(os.getcwd(), "dbg")
49
+ >>> from imgui_debugger._assets import data_dir
50
+ >>> data_dir().is_dir()
51
+ True
52
+ """
53
+ base = os.environ.get("IMGUI_DEBUGGER_HOME")
54
+ d = Path(base) if base else (Path.home() / ".imgui_debugger")
55
+ d.mkdir(parents=True, exist_ok=True)
56
+ return d
57
+
58
+
59
+ def user_assets_dir() -> Path:
60
+ """``<data dir>/assets`` — an optional user assets folder, never created here.
61
+
62
+ Examples
63
+ --------
64
+ >>> from imgui_debugger._assets import user_assets_dir
65
+ >>> user_assets_dir().name
66
+ 'assets'
67
+ """
68
+ return data_dir() / "assets"
69
+
70
+
71
+ def default_ini_path(name: str = "debugger") -> str:
72
+ """Absolute path for hello_imgui's window-layout ``.ini``.
73
+
74
+ Parameters
75
+ ----------
76
+ name : str
77
+ File stem, so several debugger windows can keep separate layouts.
78
+
79
+ Examples
80
+ --------
81
+ >>> from imgui_debugger._assets import default_ini_path
82
+ >>> default_ini_path("panel").endswith("panel.ini")
83
+ True
84
+ """
85
+ return str(data_dir() / f"{name}.ini")
86
+
87
+
88
+ def ensure_assets(assets_folder: Optional[str] = None) -> None:
89
+ """Make sure hello_imgui can resolve the FontAwesome icon font.
90
+
91
+ Passing ``assets_folder`` sets it as *the* assets folder; with no argument a
92
+ host app's already-working configuration is left untouched.
93
+
94
+ Parameters
95
+ ----------
96
+ assets_folder : str | None
97
+ Folder containing ``fonts/Font_Awesome_6_Free-Solid-900.otf``.
98
+
99
+ Examples
100
+ --------
101
+ >>> from imgui_debugger import ensure_assets
102
+ >>> ensure_assets() # doctest: +SKIP
103
+ >>> ensure_assets("/opt/myapp/assets") # doctest: +SKIP
104
+ """
105
+ from imgui_bundle import hello_imgui
106
+
107
+ if assets_folder:
108
+ hello_imgui.set_assets_folder(str(assets_folder))
109
+ return
110
+ try:
111
+ if hello_imgui.asset_exists(_ICON_FONT):
112
+ return
113
+ except Exception:
114
+ pass
115
+ user = user_assets_dir()
116
+ if user.is_dir():
117
+ hello_imgui.add_assets_search_path(str(user))
118
+ try:
119
+ if hello_imgui.asset_exists(_ICON_FONT):
120
+ return
121
+ except Exception:
122
+ pass
123
+ folder = imgui_bundle_assets_dir()
124
+ if folder:
125
+ hello_imgui.add_assets_search_path(folder)