py-imgui-redux 4.0.1__cp313-cp313-macosx_11_0_arm64.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.
- imgui/__init__.pyi +4474 -0
- imgui/glfw/__init__.pyi +1032 -0
- imgui/imnodes/__init__.pyi +505 -0
- imgui/implot/__init__.pyi +1305 -0
- imgui.cpython-313-darwin.so +0 -0
- py_imgui_redux-4.0.1.dist-info/METADATA +276 -0
- py_imgui_redux-4.0.1.dist-info/RECORD +10 -0
- py_imgui_redux-4.0.1.dist-info/WHEEL +6 -0
- py_imgui_redux-4.0.1.dist-info/licenses/LICENSE +21 -0
- py_imgui_redux-4.0.1.dist-info/top_level.txt +1 -0
|
Binary file
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py-imgui-redux
|
|
3
|
+
Version: 4.0.1
|
|
4
|
+
Summary: A python wrapper for DearImGUI and popular extensions
|
|
5
|
+
Author: Alagyn
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/alagyn/py-imgui-redux
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/alagyn/py-imgui-redux/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
<img src="https://github.com/alagyn/py-imgui-redux/blob/main/docs/pyimgui-logo-512.png?raw=true" width="256" align="right"/>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# PyImGui
|
|
24
|
+
DearImGui wrapper for python made with PyBind11
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
Read below for adjustments made to the standard APIs.
|
|
29
|
+
Otherwise, all documentation from the original libraries remains 100% valid.
|
|
30
|
+
Check out the examples folder for some concrete code.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
Install the latest version with pip
|
|
35
|
+
```
|
|
36
|
+
pip install py-imgui-redux
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Modules:
|
|
40
|
+
|
|
41
|
+
`imgui` - [Core DearImGUI](https://github.com/ocornut/imgui)
|
|
42
|
+
`imgui.implot` - [ImPlot library](https://github.com/epezent/implot)
|
|
43
|
+
`imgui.imnodes` - [ImNodes library](https://github.com/Nelarius/imnodes)
|
|
44
|
+
`imgui.glfw` - [GLFW Bindings](https://www.glfw.org)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Backends:
|
|
48
|
+
|
|
49
|
+
This module only uses the GFLW+OpenGL3 backend. `imgui.glfw` provides full access to GLFW's API, see below for it's adjustments
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## API Adjustments
|
|
54
|
+
|
|
55
|
+
I am writing this library with the primary goal of keeping the original Dear ImGui functional
|
|
56
|
+
API as intact as possible. This is because:
|
|
57
|
+
1. I want to keep all C++ examples and documentation as relevant as possible since I am lazy and don't want to rewrite everything.
|
|
58
|
+
2. I have a love-hate relationship with snake-case.
|
|
59
|
+
|
|
60
|
+
However, there are some minor compromises that have to be made in order to make this happen, primarily in the case of pointers and lists.
|
|
61
|
+
|
|
62
|
+
### Pointers
|
|
63
|
+
|
|
64
|
+
Take for instance the function:
|
|
65
|
+
```c++
|
|
66
|
+
bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, /* other args... */);
|
|
67
|
+
```
|
|
68
|
+
1. This function returns true if the state changed
|
|
69
|
+
2. `v_current_min` and `v_current_max` are pointers to state, and will be read and updated if a change is made
|
|
70
|
+
|
|
71
|
+
Typical C++ usage
|
|
72
|
+
```c++
|
|
73
|
+
int min = 0;
|
|
74
|
+
int max = 5;
|
|
75
|
+
// Code ...
|
|
76
|
+
if(imgui::DragIntRange2("Label", &min, &max))
|
|
77
|
+
{
|
|
78
|
+
// Code that happens if a change was made
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Python, however, will not let you pass an integer by reference normally, let alone across the C API.
|
|
83
|
+
Therefore, the py-imgui-redux method of accomplishing this:
|
|
84
|
+
```python
|
|
85
|
+
min_val = imgui.IntRef(0)
|
|
86
|
+
max_val = imgui.IntRef(5)
|
|
87
|
+
# Code ...
|
|
88
|
+
if imgui.DragIntRange2("Label", min_val, max_val):
|
|
89
|
+
# Code that happens if a change was made
|
|
90
|
+
pass
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
These are thin wrappers around a single value.
|
|
94
|
+
```python
|
|
95
|
+
imgui.IntRef
|
|
96
|
+
imgui.FloatRef
|
|
97
|
+
imgui.BoolRef
|
|
98
|
+
# The value can be accessed like so
|
|
99
|
+
myNum = imgui.IntRef(25)
|
|
100
|
+
myNum.val += 2
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### Lists
|
|
106
|
+
|
|
107
|
+
Take for instance the function
|
|
108
|
+
```c++
|
|
109
|
+
bool DragInt3(const char* label, int v[3], /* args ... */);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
A standard python list is stored sequentially in memory, but the raw *values* themselves are wrapped in a python object. Therefore, we cannot easily iterate over *just* the ints/floats, let alone get a pointer to give to ImGui. PyBind11 will happily take a python list and turn it into a vector for us, but in doing so requires making a copy of the list (not ideal for large lists)
|
|
113
|
+
|
|
114
|
+
This is solved in one of two ways.
|
|
115
|
+
|
|
116
|
+
Method 1: py-imgui-redux Wrappers
|
|
117
|
+
```python
|
|
118
|
+
vals = imgui.IntList([0, 5, 10])
|
|
119
|
+
if imgui.DragInt3("Label", vals):
|
|
120
|
+
# updating code
|
|
121
|
+
pass
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
These are thin wrappers around a C++ vector. They have standard
|
|
125
|
+
python list access functions and iteration capabilities.
|
|
126
|
+
```python
|
|
127
|
+
imgui.IntList
|
|
128
|
+
imgui.FloatList
|
|
129
|
+
imgui.DoubleList
|
|
130
|
+
|
|
131
|
+
x = imgui.IntList()
|
|
132
|
+
x.append(25)
|
|
133
|
+
x.append(36)
|
|
134
|
+
|
|
135
|
+
print(len(x))
|
|
136
|
+
|
|
137
|
+
for val in x:
|
|
138
|
+
print(x)
|
|
139
|
+
|
|
140
|
+
x[0] = 12
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
See their docs for more information and all functions.
|
|
144
|
+
|
|
145
|
+
Functions that mutate the data, such as vanilla ImGui widgets will
|
|
146
|
+
use this method.
|
|
147
|
+
|
|
148
|
+
Method 2: Numpy Arrays
|
|
149
|
+
```python
|
|
150
|
+
import numpy as np
|
|
151
|
+
xs = np.array([0, 5, 10])
|
|
152
|
+
ys = np.array([0, 5, 10])
|
|
153
|
+
# Code...
|
|
154
|
+
implot.PlotScatter("Scatter", xs, ys, len(xs))
|
|
155
|
+
```
|
|
156
|
+
The implot submodule uses these, as they prevent the need to copy potentially large arrays, and implot functions will not need to change the data as it reads it. Numpy
|
|
157
|
+
is also easier to use for data manipulations as is typical with plotting.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
Thirdly, references to strings are handled similarily to lists (it's actually a subclass of the List wrappers).
|
|
161
|
+
|
|
162
|
+
Take for instance the function
|
|
163
|
+
```c++
|
|
164
|
+
bool InputText(const char* label, char* buf, size_t buf_size, /* args ... */);
|
|
165
|
+
```
|
|
166
|
+
Which takes a pointer to the IO buffer, and also and argument for its size.
|
|
167
|
+
|
|
168
|
+
In Python:
|
|
169
|
+
```python
|
|
170
|
+
myStr = imgui.StrRef("This is a string", maxSize=20)
|
|
171
|
+
# Code ...
|
|
172
|
+
if imgui.InputText("Label", myStr):
|
|
173
|
+
# code if the text changes
|
|
174
|
+
pass
|
|
175
|
+
```
|
|
176
|
+
Notice that you don't need to pass the size, this is baked into the StrRef.
|
|
177
|
+
Note: `maxSize` automatically takes into account string terminators, i.e. `maxSize=20` means
|
|
178
|
+
your string can hold 20 chars.
|
|
179
|
+
|
|
180
|
+
To change the maxSize:
|
|
181
|
+
```python
|
|
182
|
+
myStr.resize(25)
|
|
183
|
+
```
|
|
184
|
+
Changing the size lower will drop any extra chars.
|
|
185
|
+
|
|
186
|
+
To get your string back
|
|
187
|
+
```python
|
|
188
|
+
# make a copy
|
|
189
|
+
x = str(myStr)
|
|
190
|
+
# or
|
|
191
|
+
x = myStr.copy()
|
|
192
|
+
|
|
193
|
+
# get a temporary/unsafe pointer
|
|
194
|
+
# useful for printing large strings without copying
|
|
195
|
+
# only use said pointer while the object exists
|
|
196
|
+
# lest ye summon the dreaded seg-fault
|
|
197
|
+
print(myStr.view())
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### Images
|
|
203
|
+
|
|
204
|
+
Loading images for rendering is simple
|
|
205
|
+
```python
|
|
206
|
+
import imgui
|
|
207
|
+
|
|
208
|
+
texture = imgui.LoadTextureFile("myImage.jpg")
|
|
209
|
+
imgui.Image(texture, imgui.ImVec2(texture.width, texture.height))
|
|
210
|
+
# ...
|
|
211
|
+
# Eventually
|
|
212
|
+
glfw.UnloadTexture(texture)
|
|
213
|
+
# texture can no longer be used without a call to LoadTexture
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Image file loading is handled via [stb_image](https://github.com/nothings/stb/blob/master/stb_image.h) and supports various common file formats.
|
|
217
|
+
Alternatively, if you wish to do some manual image processing, you can use PILLOW or OpenCV
|
|
218
|
+
(or any other image processing library... probably)
|
|
219
|
+
|
|
220
|
+
**Important Note: `LoadTexture` and `LoadTextureFile` can only be called after both imgui and glfw have been initialized otherwise openGL will segfault**
|
|
221
|
+
|
|
222
|
+
**OpenCV Example**
|
|
223
|
+
```python
|
|
224
|
+
import imgui
|
|
225
|
+
import cv2
|
|
226
|
+
|
|
227
|
+
image = cv2.imread("myImage.jpg", cv2.IMREAD_UNCHANGED)
|
|
228
|
+
# cv2.IMREAD_UNCHANGED is important for files with alpha
|
|
229
|
+
|
|
230
|
+
# Have to convert the colors first
|
|
231
|
+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
|
232
|
+
# If your image has alpha: cv2.COLOR_GBRA2RGBA
|
|
233
|
+
|
|
234
|
+
texture = imgui.LoadTexture(image.tobytes(),
|
|
235
|
+
image.shape[1],
|
|
236
|
+
image.shape[0],
|
|
237
|
+
image.shape[2])
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**PILLOW Example**
|
|
242
|
+
```python
|
|
243
|
+
import imgui
|
|
244
|
+
from PIL import Image
|
|
245
|
+
|
|
246
|
+
image = Image.open("myImage.jpg")
|
|
247
|
+
texture = imgui.LoadTexture(image.tobytes(),
|
|
248
|
+
image.size[0],
|
|
249
|
+
image.size[1],
|
|
250
|
+
len(image.getbands()))
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### GLFW API Adjustments
|
|
255
|
+
|
|
256
|
+
This wrapper aims to be as close to the original API as possible.
|
|
257
|
+
Exceptions:
|
|
258
|
+
- Functions have lost the `glfw` prefix as this is already in the module name
|
|
259
|
+
- Functions that returned pointers to arrays now return list-like objects
|
|
260
|
+
- Functions that took pointers to output variables as arguments now return tuples
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### Build Dependencies
|
|
266
|
+
|
|
267
|
+
**Debian/apt**
|
|
268
|
+
```
|
|
269
|
+
libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Fedora/yum**
|
|
273
|
+
```
|
|
274
|
+
libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel mesa-libGL-devel
|
|
275
|
+
```
|
|
276
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
imgui.cpython-313-darwin.so,sha256=tzq1NNk-XnwEViC2rE53WwKeMdi3m-No4MgjUc4QLTA,6077672
|
|
2
|
+
imgui/__init__.pyi,sha256=Aru4qMkMrtZ2m1sUtIONJbh7eDDIiNjPL0mVt2bzcgM,128407
|
|
3
|
+
imgui/implot/__init__.pyi,sha256=4QmGV1bJm5ME7OqkPNYXC1zqL8ZtNwt290199rTO-Mc,45216
|
|
4
|
+
imgui/imnodes/__init__.pyi,sha256=pIQi7lyJaQew3wk1_R-Cw_posVsR80OmtivIq4CqFJI,14169
|
|
5
|
+
imgui/glfw/__init__.pyi,sha256=RSwFYzbiktb-AF5vQu9E7wPrp0Nfe9Vse01qjOUVX3A,26974
|
|
6
|
+
py_imgui_redux-4.0.1.dist-info/RECORD,,
|
|
7
|
+
py_imgui_redux-4.0.1.dist-info/WHEEL,sha256=oqGJCpG61FZJmvyZ3C_0aCv-2mdfcY9e3fXvyUNmWfM,136
|
|
8
|
+
py_imgui_redux-4.0.1.dist-info/top_level.txt,sha256=15onHRujL1_V625VUUaELFCxh9bOaAi5IzpVBJIPyHI,6
|
|
9
|
+
py_imgui_redux-4.0.1.dist-info/METADATA,sha256=ZmM0aX7B4kbKdUzqYXnyuY_PTSccjSph_nPzBQ6R35Y,7794
|
|
10
|
+
py_imgui_redux-4.0.1.dist-info/licenses/LICENSE,sha256=fDrCLKI_lLbO88WTSx4QGbbOEZrWhcw0TBLOQxkydX4,1070
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Ben Kimbrough
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
imgui
|