Ara-imgui 1.0.0__tar.gz

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,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: Ara_imgui
3
+ Version: 1.0.0
4
+ Summary: A simplified wrapper for Dear ImGui and GLFW
5
+ Author-email: HanamileH <hanamileh@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/hanamileh-DEV/Ara_imgui
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: glfw>=2.8.0
11
+ Requires-Dist: imgui==2.0.0
12
+ Requires-Dist: pyopengl>=3.1.9
13
+
14
+ # Ara_imgui
15
+
16
+ **Ara_imgui** is a lightweight and easy-to-use wrapper around [Dear ImGui](https://github.com/ocornut/imgui) using Python and GLFW. It simplifies GUI application development with ImGui by providing a convenient interface for managing windows, fonts, and application lifecycle.
17
+
18
+ ## Features
19
+
20
+ - Simple ImGui app launch with a single `run` function
21
+ - Support for multiple ImGui windows via the `Window` class
22
+ - Built-in dark and light themes
23
+ - System or custom font loading, including Cyrillic support
24
+ - Ready-to-run examples included in the `examples` folder
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install ara_imgui
30
+ ````
31
+
32
+ Or install dependencies manually:
33
+
34
+ ```bash
35
+ pip install glfw PyOpenGL imgui
36
+ ```
37
+
38
+ > ⚠️ Make sure you have Python 3.7+ and OpenGL support (e.g., via GPU drivers on Windows).
39
+
40
+ ## Usage
41
+
42
+ ### Basic example
43
+
44
+ ```python
45
+ from ara_imgui import run, imgui
46
+
47
+ def gui():
48
+ imgui.text("Hello, world!")
49
+ if imgui.button("Click me"):
50
+ print("Clicked!")
51
+
52
+ run(gui)
53
+ ```
54
+
55
+ ### Multiple windows
56
+
57
+ ```python
58
+ from ara_imgui import App, Window, imgui
59
+
60
+ app = App("Multi-window App")
61
+
62
+ def win_ui():
63
+ imgui.text("This is another window")
64
+
65
+ win = Window("Extra Window", frame_ui=win_ui)
66
+
67
+ def main_ui():
68
+ imgui.text("Main Window")
69
+ if imgui.button("Open Extra Window"):
70
+ app.add_window(win)
71
+
72
+ app.run(main_ui)
73
+ ```
74
+
75
+ ### Custom fonts and themes
76
+
77
+ ```python
78
+ from ara_imgui import App, imgui
79
+
80
+ app = App("Font Example")
81
+ app.apply_theme("light")
82
+ app.load_font(font_size=18)
83
+
84
+ def gui():
85
+ imgui.text("Sample text with custom font")
86
+
87
+ app.run(gui)
88
+ ```
89
+
90
+ ## API
91
+
92
+ ### `run(frame_ui, **kwargs)`
93
+
94
+ Minimal interface to launch the application.
95
+
96
+ Parameters:
97
+
98
+ * `frame_ui`: Function to render the main UI.
99
+ * `callback`: Function called after `frame_ui` (optional).
100
+ * `title`: Window title.
101
+ * `width`, `height`: Window size.
102
+ * `theme`: `"dark"` or `"light"`.
103
+ * `custom_font`: `False`, `True`, or path to a `.ttf` file.
104
+ * `font_size`: Font size.
105
+ * `cyrillic_ranges`: Include Cyrillic character ranges (`True` by default).
106
+
107
+ ### Classes
108
+
109
+ * `App` — The main application class.
110
+ * `Window` — Represents a separate ImGui window with its own logic.
111
+
112
+ ## Examples
113
+
114
+ See the [`examples/`](./examples) folder:
115
+
116
+ * `hello_world.py` — Basic "Hello, world!" with a button.
117
+ * `basic_window.py` — Simple window with input field.
118
+ * `custom_font.py` — Font and multilingual text rendering.
119
+ * `multiple_window.py` — GUI with multiple ImGui windows.
120
+
121
+ ## Dependencies
122
+
123
+ * `imgui`
124
+ * `glfw`
125
+ * `PyOpenGL`
126
+
127
+ ## License
128
+
129
+ MIT License. Free to use and modify.
@@ -0,0 +1,116 @@
1
+ # Ara_imgui
2
+
3
+ **Ara_imgui** is a lightweight and easy-to-use wrapper around [Dear ImGui](https://github.com/ocornut/imgui) using Python and GLFW. It simplifies GUI application development with ImGui by providing a convenient interface for managing windows, fonts, and application lifecycle.
4
+
5
+ ## Features
6
+
7
+ - Simple ImGui app launch with a single `run` function
8
+ - Support for multiple ImGui windows via the `Window` class
9
+ - Built-in dark and light themes
10
+ - System or custom font loading, including Cyrillic support
11
+ - Ready-to-run examples included in the `examples` folder
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install ara_imgui
17
+ ````
18
+
19
+ Or install dependencies manually:
20
+
21
+ ```bash
22
+ pip install glfw PyOpenGL imgui
23
+ ```
24
+
25
+ > ⚠️ Make sure you have Python 3.7+ and OpenGL support (e.g., via GPU drivers on Windows).
26
+
27
+ ## Usage
28
+
29
+ ### Basic example
30
+
31
+ ```python
32
+ from ara_imgui import run, imgui
33
+
34
+ def gui():
35
+ imgui.text("Hello, world!")
36
+ if imgui.button("Click me"):
37
+ print("Clicked!")
38
+
39
+ run(gui)
40
+ ```
41
+
42
+ ### Multiple windows
43
+
44
+ ```python
45
+ from ara_imgui import App, Window, imgui
46
+
47
+ app = App("Multi-window App")
48
+
49
+ def win_ui():
50
+ imgui.text("This is another window")
51
+
52
+ win = Window("Extra Window", frame_ui=win_ui)
53
+
54
+ def main_ui():
55
+ imgui.text("Main Window")
56
+ if imgui.button("Open Extra Window"):
57
+ app.add_window(win)
58
+
59
+ app.run(main_ui)
60
+ ```
61
+
62
+ ### Custom fonts and themes
63
+
64
+ ```python
65
+ from ara_imgui import App, imgui
66
+
67
+ app = App("Font Example")
68
+ app.apply_theme("light")
69
+ app.load_font(font_size=18)
70
+
71
+ def gui():
72
+ imgui.text("Sample text with custom font")
73
+
74
+ app.run(gui)
75
+ ```
76
+
77
+ ## API
78
+
79
+ ### `run(frame_ui, **kwargs)`
80
+
81
+ Minimal interface to launch the application.
82
+
83
+ Parameters:
84
+
85
+ * `frame_ui`: Function to render the main UI.
86
+ * `callback`: Function called after `frame_ui` (optional).
87
+ * `title`: Window title.
88
+ * `width`, `height`: Window size.
89
+ * `theme`: `"dark"` or `"light"`.
90
+ * `custom_font`: `False`, `True`, or path to a `.ttf` file.
91
+ * `font_size`: Font size.
92
+ * `cyrillic_ranges`: Include Cyrillic character ranges (`True` by default).
93
+
94
+ ### Classes
95
+
96
+ * `App` — The main application class.
97
+ * `Window` — Represents a separate ImGui window with its own logic.
98
+
99
+ ## Examples
100
+
101
+ See the [`examples/`](./examples) folder:
102
+
103
+ * `hello_world.py` — Basic "Hello, world!" with a button.
104
+ * `basic_window.py` — Simple window with input field.
105
+ * `custom_font.py` — Font and multilingual text rendering.
106
+ * `multiple_window.py` — GUI with multiple ImGui windows.
107
+
108
+ ## Dependencies
109
+
110
+ * `imgui`
111
+ * `glfw`
112
+ * `PyOpenGL`
113
+
114
+ ## License
115
+
116
+ MIT License. Free to use and modify.
@@ -0,0 +1,21 @@
1
+ [project]
2
+ name = "Ara_imgui"
3
+ version = "1.0.0"
4
+ description = "A simplified wrapper for Dear ImGui and GLFW"
5
+ readme = "README.md"
6
+ authors = [{ name = "HanamileH", email = "hanamileh@gmail.com" }]
7
+ license = "MIT"
8
+
9
+ dependencies = [
10
+ "glfw>=2.8.0",
11
+ "imgui==2.0.0",
12
+ "pyopengl>=3.1.9"
13
+ ]
14
+ requires-python = ">=3.7"
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/hanamileh-DEV/Ara_imgui"
18
+
19
+ [build-system]
20
+ requires = ["setuptools", "wheel"]
21
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: Ara_imgui
3
+ Version: 1.0.0
4
+ Summary: A simplified wrapper for Dear ImGui and GLFW
5
+ Author-email: HanamileH <hanamileh@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/hanamileh-DEV/Ara_imgui
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: glfw>=2.8.0
11
+ Requires-Dist: imgui==2.0.0
12
+ Requires-Dist: pyopengl>=3.1.9
13
+
14
+ # Ara_imgui
15
+
16
+ **Ara_imgui** is a lightweight and easy-to-use wrapper around [Dear ImGui](https://github.com/ocornut/imgui) using Python and GLFW. It simplifies GUI application development with ImGui by providing a convenient interface for managing windows, fonts, and application lifecycle.
17
+
18
+ ## Features
19
+
20
+ - Simple ImGui app launch with a single `run` function
21
+ - Support for multiple ImGui windows via the `Window` class
22
+ - Built-in dark and light themes
23
+ - System or custom font loading, including Cyrillic support
24
+ - Ready-to-run examples included in the `examples` folder
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install ara_imgui
30
+ ````
31
+
32
+ Or install dependencies manually:
33
+
34
+ ```bash
35
+ pip install glfw PyOpenGL imgui
36
+ ```
37
+
38
+ > ⚠️ Make sure you have Python 3.7+ and OpenGL support (e.g., via GPU drivers on Windows).
39
+
40
+ ## Usage
41
+
42
+ ### Basic example
43
+
44
+ ```python
45
+ from ara_imgui import run, imgui
46
+
47
+ def gui():
48
+ imgui.text("Hello, world!")
49
+ if imgui.button("Click me"):
50
+ print("Clicked!")
51
+
52
+ run(gui)
53
+ ```
54
+
55
+ ### Multiple windows
56
+
57
+ ```python
58
+ from ara_imgui import App, Window, imgui
59
+
60
+ app = App("Multi-window App")
61
+
62
+ def win_ui():
63
+ imgui.text("This is another window")
64
+
65
+ win = Window("Extra Window", frame_ui=win_ui)
66
+
67
+ def main_ui():
68
+ imgui.text("Main Window")
69
+ if imgui.button("Open Extra Window"):
70
+ app.add_window(win)
71
+
72
+ app.run(main_ui)
73
+ ```
74
+
75
+ ### Custom fonts and themes
76
+
77
+ ```python
78
+ from ara_imgui import App, imgui
79
+
80
+ app = App("Font Example")
81
+ app.apply_theme("light")
82
+ app.load_font(font_size=18)
83
+
84
+ def gui():
85
+ imgui.text("Sample text with custom font")
86
+
87
+ app.run(gui)
88
+ ```
89
+
90
+ ## API
91
+
92
+ ### `run(frame_ui, **kwargs)`
93
+
94
+ Minimal interface to launch the application.
95
+
96
+ Parameters:
97
+
98
+ * `frame_ui`: Function to render the main UI.
99
+ * `callback`: Function called after `frame_ui` (optional).
100
+ * `title`: Window title.
101
+ * `width`, `height`: Window size.
102
+ * `theme`: `"dark"` or `"light"`.
103
+ * `custom_font`: `False`, `True`, or path to a `.ttf` file.
104
+ * `font_size`: Font size.
105
+ * `cyrillic_ranges`: Include Cyrillic character ranges (`True` by default).
106
+
107
+ ### Classes
108
+
109
+ * `App` — The main application class.
110
+ * `Window` — Represents a separate ImGui window with its own logic.
111
+
112
+ ## Examples
113
+
114
+ See the [`examples/`](./examples) folder:
115
+
116
+ * `hello_world.py` — Basic "Hello, world!" with a button.
117
+ * `basic_window.py` — Simple window with input field.
118
+ * `custom_font.py` — Font and multilingual text rendering.
119
+ * `multiple_window.py` — GUI with multiple ImGui windows.
120
+
121
+ ## Dependencies
122
+
123
+ * `imgui`
124
+ * `glfw`
125
+ * `PyOpenGL`
126
+
127
+ ## License
128
+
129
+ MIT License. Free to use and modify.
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/Ara_imgui.egg-info/PKG-INFO
4
+ src/Ara_imgui.egg-info/SOURCES.txt
5
+ src/Ara_imgui.egg-info/dependency_links.txt
6
+ src/Ara_imgui.egg-info/requires.txt
7
+ src/Ara_imgui.egg-info/top_level.txt
8
+ src/ara_imgui/__init__.py
9
+ src/ara_imgui/app.py
10
+ src/ara_imgui/window.py
11
+ tests/test_basic.py
@@ -0,0 +1,3 @@
1
+ glfw>=2.8.0
2
+ imgui==2.0.0
3
+ pyopengl>=3.1.9
@@ -0,0 +1 @@
1
+ ara_imgui
@@ -0,0 +1,5 @@
1
+ import imgui
2
+ from .app import App, run
3
+ from .window import Window
4
+
5
+ __all__ = ['App', 'run', 'Window', 'imgui']
@@ -0,0 +1,231 @@
1
+ import os
2
+ import sys
3
+ from pathlib import Path
4
+ import inspect
5
+ import glfw
6
+ import imgui
7
+ from imgui.integrations.glfw import GlfwRenderer # GLFW integration for ImGui
8
+ from .window import Window
9
+
10
+ class App:
11
+ """
12
+ A class representing an ImGui application.
13
+
14
+ Attributes:
15
+ title (str): The title of the application window.
16
+ width (int): The width of the application window.
17
+ height (int): The height of the application window.
18
+ window (GLFWwindow): The GLFW window object.
19
+ renderer (GlfwRenderer): The ImGui GLFW renderer.
20
+ windows (set): A set of Window instances.
21
+ """
22
+ def __init__(self, title="New app", width=800, height=600):
23
+ """
24
+ Initializes the App instance.
25
+
26
+ Args:
27
+ title (str, optional): The title of the application window. Defaults to "New app".
28
+ width (int, optional): The width of the application window. Defaults to 800.
29
+ height (int, optional): The height of the application window. Defaults to 600.
30
+ """
31
+ # Initialize GLFW
32
+ if not glfw.init():
33
+ raise Exception("Failed to initialize GLFW")
34
+
35
+ # Set window properties
36
+ self.title = title
37
+ self.width = width
38
+ self.height = height
39
+
40
+ # Create GLFW window
41
+ self.window = glfw.create_window(width, height, title, None, None)
42
+
43
+ if not self.window:
44
+ glfw.terminate()
45
+ raise Exception("Failed to create GLFW window")
46
+
47
+ # Set up OpenGL context and vsync
48
+ glfw.make_context_current(self.window)
49
+ glfw.swap_interval(1) # Enable vsync
50
+
51
+ # Initialize ImGui context and GLFW renderer
52
+ imgui.create_context()
53
+ self.renderer = GlfwRenderer(self.window)
54
+
55
+ # ImGui windows
56
+ self.windows = set()
57
+
58
+
59
+ def load_font(self, font_path=None, font_size=14, cyrillic_ranges=True):
60
+ """
61
+ Loads a font for the application.
62
+
63
+ Args:
64
+ font_path (str, optional): The path to the font file. Defaults to None, which loads the default font.
65
+ font_size (int, optional): The size of the font. Defaults to 14.
66
+ cyrillic_ranges (bool, optional): Whether to include Cyrillic character ranges. Defaults to True.
67
+ """
68
+ # Loading default font
69
+ if font_path is None:
70
+ if sys.platform == "win32":
71
+ font_path = Path("C:/Windows/Fonts/segoeui.ttf")
72
+ elif sys.platform == "darwin":
73
+ font_path = Path("/System/Library/Fonts/SFNSDisplay.ttf")
74
+ elif sys.platform == "linux":
75
+ font_path = Path("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
76
+ else:
77
+ raise Exception(f"Unsupported platform {sys.platform}")
78
+
79
+ # Check if font file exists
80
+ if not os.path.exists(font_path):
81
+ raise Exception(f"Font file {font_path} does not exist")
82
+
83
+ # Loading font
84
+ io = imgui.get_io()
85
+
86
+ glyph_ranges = io.fonts.get_glyph_ranges_default()
87
+
88
+ if cyrillic_ranges:
89
+ glyph_ranges = io.fonts.get_glyph_ranges_cyrillic()
90
+
91
+ io.fonts.clear()
92
+ io.fonts.add_font_from_file_ttf(str(font_path), font_size, None, glyph_ranges)
93
+ self.renderer.refresh_font_texture()
94
+
95
+
96
+ def apply_theme(self, name: str):
97
+ """
98
+ Applies a theme to the application.
99
+
100
+ Args:
101
+ name (str): The name of the theme ("dark" or "light").
102
+ """
103
+ if name == "dark":
104
+ imgui.style_colors_dark()
105
+ elif name == "light":
106
+ imgui.style_colors_light()
107
+ else:
108
+ raise ValueError(f"Unknown theme name: {name}. Available themes: 'dark', 'light'")
109
+
110
+
111
+ def add_window(self, window: Window):
112
+ """
113
+ Adds a window to the application.
114
+
115
+ Args:
116
+ window (Window): The Window instance to add.
117
+
118
+ Returns:
119
+ bool: True if the window was added, False if it was already present.
120
+ """
121
+ window.should_close = False
122
+ if window not in self.windows:
123
+ self.windows.add(window)
124
+ return True
125
+ else:
126
+ return False
127
+
128
+
129
+ def run(self, frame_ui = None, callback = None):
130
+ """
131
+ Executes the main application loop.
132
+
133
+ Args:
134
+ frame_ui (function, optional): The function to draw the main UI. Defaults to None.
135
+ callback (function, optional): The function to call after drawing the UI. Defaults to None.
136
+ """
137
+
138
+ while not glfw.window_should_close(self.window):
139
+ # Process events and inputs
140
+ glfw.poll_events()
141
+ self.renderer.process_inputs()
142
+
143
+ # Start new ImGui frame
144
+ imgui.new_frame()
145
+
146
+ # Get current window size
147
+ self.width, self.height = glfw.get_framebuffer_size(self.window)
148
+
149
+ # Set up fullscreen window for ImGui main window
150
+ imgui.set_next_window_position(0, 0)
151
+ imgui.set_next_window_size(self.width, self.height)
152
+ imgui.begin(
153
+ f"##{self.title}",
154
+ flags=imgui.WINDOW_NO_DECORATION |
155
+ imgui.WINDOW_NO_MOVE |
156
+ imgui.WINDOW_NO_BRING_TO_FRONT_ON_FOCUS
157
+ )
158
+
159
+ # Call UI rendering callback if set
160
+ if frame_ui:
161
+ sig = inspect.signature(frame_ui)
162
+ if len(sig.parameters) == 0:
163
+ frame_ui()
164
+ elif len(sig.parameters) == 1:
165
+ frame_ui(self)
166
+ else:
167
+ raise TypeError(f"frame_ui function must take 0 or 1 arguments, but {len(sig.parameters)} were given")
168
+
169
+ imgui.end()
170
+
171
+ # Drawing ImGui windows
172
+ self.windows = set([window for window in self.windows if not window.should_close])
173
+
174
+ for window in self.windows:
175
+ window.draw()
176
+
177
+ # Call frame update callback if set
178
+ if callback:
179
+ sig = inspect.signature(callback)
180
+ if len(sig.parameters) == 0:
181
+ callback()
182
+ elif len(sig.parameters) == 1:
183
+ callback(self)
184
+ else:
185
+ raise TypeError(f"callback function must take 0 or 1 arguments, but {len(sig.parameters)} were given")
186
+
187
+ # Render ImGui and swap buffers
188
+ imgui.render()
189
+ self.renderer.render(imgui.get_draw_data())
190
+ glfw.swap_buffers(self.window)
191
+
192
+ # Cleanup on exit
193
+ self.renderer.shutdown()
194
+ glfw.terminate()
195
+
196
+
197
+ def run(
198
+ frame_ui,
199
+ callback=None,
200
+ title="New app",
201
+ width=800,
202
+ height=600,
203
+ theme="dark",
204
+ custom_font=False,
205
+ font_size=14,
206
+ cyrillic_ranges=True
207
+ ):
208
+ """
209
+ A minimalistic, easy-to-use function for creating and running an app.
210
+
211
+ Args:
212
+ frame_ui (function): The function to draw the main UI.
213
+ callback (function, optional): The function to call after drawing the UI. Defaults to None.
214
+ title (str, optional): The title of the application window. Defaults to "New app".
215
+ width (int, optional): The width of the application window. Defaults to 800.
216
+ height (int, optional): The height of the application window. Defaults to 600.
217
+ theme (str, optional): The name of the theme ("dark" or "light"). Defaults to "dark".
218
+ custom_font (bool or str, optional): The path to a custom font or True to use the default font or False to use build-in ImGui font. Defaults to False.
219
+ font_size (int, optional): The size of the font. Defaults to 14.
220
+ cyrillic_ranges (bool, optional): Whether to include Cyrillic character ranges. Defaults to True.
221
+ """
222
+
223
+ app = App(title, width, height)
224
+
225
+ if custom_font == True:
226
+ app.load_font(font_size=font_size, cyrillic_ranges=cyrillic_ranges)
227
+ elif type(custom_font) == str:
228
+ app.load_font(font_path=custom_font, font_size=font_size, cyrillic_ranges=cyrillic_ranges)
229
+
230
+ app.apply_theme(theme)
231
+ app.run(frame_ui, callback)
@@ -0,0 +1,95 @@
1
+ import inspect
2
+ import imgui
3
+
4
+ class Window:
5
+ """
6
+ A class representing an ImGui window.
7
+
8
+ Attributes:
9
+ name (str): The title of the window.
10
+ flags (int): The flags for the window.
11
+ frame_ui (function): The function to draw the window's content.
12
+ should_close (bool): A flag indicating if the window should be closed.
13
+ _internal_id (int): The unique ID for the window.
14
+ next_size (tuple, None): The next size of the window.
15
+ next_pos (tuple, None): The next position of the window.
16
+ """
17
+ def __init__(self, title, flags=0, frame_ui=None):
18
+ """
19
+ Initializes the Window instance.
20
+
21
+ Args:
22
+ title (str): The title of the window.
23
+ flags (int, optional): The ImGui flags for the window. Defaults to 0.
24
+ frame_ui (function, optional): The function to draw the window's content. Defaults to None.
25
+ """
26
+ self.name = title
27
+ self.flags = flags
28
+ self.frame_ui = frame_ui
29
+ self.should_close = False
30
+ self._internal_id = id(self)
31
+ self.next_size = None
32
+ self.next_pos = None
33
+
34
+
35
+ def set_frame_ui(self, frame_ui):
36
+ """
37
+ Sets the frame UI function for the window.
38
+
39
+ Args:
40
+ frame_ui (function): The function to draw the window's content.
41
+ """
42
+ self.frame_ui = frame_ui
43
+
44
+
45
+ def set_size(self, width: int, height: int):
46
+ """
47
+ Sets the size of the window.
48
+
49
+ Args:
50
+ width (int): The width of the window.
51
+ height (int): The height of the window.
52
+ """
53
+ self.next_size = (width, height)
54
+
55
+
56
+ def set_pos(self, x, y):
57
+ """
58
+ Sets the position of the window.
59
+
60
+ Args:
61
+ x (int): The x-coordinate of the window.
62
+ y (int): The y-coordinate of the window.
63
+ """
64
+ self.next_pos = (x, y)
65
+
66
+
67
+ def draw(self):
68
+ """
69
+ Draws the window and its content.
70
+
71
+ This method sets the size and position of the window if they have been changed,
72
+ begins the ImGui window, and calls the frame UI function if it exists.
73
+ """
74
+ if self.next_size:
75
+ imgui.set_next_window_size(self.next_size[0], self.next_size[1])
76
+ self.next_size = None
77
+
78
+ if self.next_pos:
79
+ imgui.set_next_window_position(self.next_pos[0], self.next_pos[1])
80
+ self.next_pos = None
81
+
82
+ _, is_opened = imgui.begin(f"{self.name}##{self._internal_id}", True, flags = self.flags)
83
+
84
+ self.should_close = not is_opened
85
+
86
+ if self.frame_ui is not None:
87
+ sig = inspect.signature(self.frame_ui)
88
+ if len(sig.parameters) == 0:
89
+ self.frame_ui()
90
+ elif len(sig.parameters) == 1:
91
+ self.frame_ui(self)
92
+ else:
93
+ raise TypeError(f"frame_ui function must take 0 or 1 arguments, but {len(sig.parameters)} were given")
94
+
95
+ imgui.end()
@@ -0,0 +1,8 @@
1
+ # Test if the module can be imported
2
+ def test_import():
3
+ import ara_imgui
4
+
5
+ # Test if the module can be run
6
+ def test_run_callable():
7
+ from ara_imgui import run
8
+ assert callable(run)