0
# Advanced Features
1
2
Specialized functionality including node editors, theming, resource management, file dialogs, and developer tools. These features provide advanced capabilities for complex applications and professional development workflows.
3
4
## Capabilities
5
6
### Node Editor System
7
8
```python { .api }
9
def add_node_editor(*, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
10
"""Creates a node-based visual programming interface."""
11
12
def add_node(*, label: str = '', tag: Union[int, str] = '', pos: Union[List[int], Tuple[int, ...]] = '', **kwargs) -> Union[int, str]:
13
"""Adds a node to the node editor."""
14
15
def add_node_attribute(*, label: str = '', attribute_type: int = '', shape: int = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
16
"""Adds an input/output attribute to a node."""
17
18
def add_node_link(attr_1: Union[int, str], attr_2: Union[int, str], *, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
19
"""Creates a connection between node attributes."""
20
```
21
22
### Theming System
23
24
```python { .api }
25
def add_theme(*, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
26
"""Creates a theme for styling UI elements."""
27
28
def add_theme_color(item: int, color: Union[List[int], Tuple[int, ...]], *, category: int = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
29
"""Adds a color override to a theme."""
30
31
def add_theme_style(item: int, x: float, y: float = '', *, category: int = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
32
"""Adds a style override to a theme."""
33
34
def add_theme_component(item: int, *, enabled_state: bool = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
35
"""Adds a theme component for specific item types."""
36
37
def bind_theme(theme: Union[int, str]) -> None:
38
"""Applies a theme globally."""
39
40
def bind_item_theme(item: Union[int, str], theme: Union[int, str]) -> None:
41
"""Applies a theme to a specific item."""
42
```
43
44
### Resource Management
45
46
```python { .api }
47
def add_texture_registry(*, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
48
"""Creates a registry for texture resources."""
49
50
def add_static_texture(width: int, height: int, default_value: Union[List[float], Tuple[float, ...]], *, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
51
"""Creates a static texture from raw data."""
52
53
def add_dynamic_texture(width: int, height: int, default_value: Union[List[float], Tuple[float, ...]], *, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
54
"""Creates a dynamic texture that can be updated."""
55
56
def add_font_registry(*, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
57
"""Creates a registry for font resources."""
58
59
def add_font(file: str, size: float, *, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
60
"""Loads a font from file."""
61
62
def bind_font(font: Union[int, str]) -> None:
63
"""Sets the active font globally."""
64
65
def add_colormap_registry(*, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
66
"""Creates a registry for color maps."""
67
68
def add_colormap(colors: List[Union[List[int], Tuple[int, ...]]], qualitative: bool, *, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
69
"""Creates a color map for data visualization."""
70
```
71
72
### File Operations
73
74
```python { .api }
75
def add_file_dialog(*, directory_selector: bool = '', show: bool = '', callback: Callable = '', tag: Union[int, str] = '', width: int = '', height: int = '', default_path: str = '', default_filename: str = '', file_count: int = '', modal: bool = '', **kwargs) -> Union[int, str]:
76
"""
77
Creates a file dialog for file selection.
78
79
Parameters:
80
- directory_selector (bool): Select directories instead of files
81
- callback (Callable): Function called when file is selected
82
- default_path (str): Initial directory path
83
- default_filename (str): Default filename
84
- file_count (int): Maximum number of files to select
85
- modal (bool): Modal dialog
86
87
Returns:
88
Union[int, str]: File dialog ID
89
"""
90
91
def add_file_extension(extension: str, *, color: Union[List[int], Tuple[int, ...]] = '', custom_text: str = '', **kwargs) -> Union[int, str]:
92
"""Adds a file extension filter to a file dialog."""
93
94
def get_file_dialog_info(file_dialog: Union[int, str]) -> dict:
95
"""Gets information about the selected file(s)."""
96
97
def load_image(file: str) -> Union[List[int], Tuple[int, ...]]:
98
"""
99
Loads an image file.
100
101
Returns:
102
tuple: (width, height, channels, data)
103
"""
104
105
def save_image(file: str, width: int, height: int, data: Union[List[float], Tuple[float, ...]], *, components: int = '') -> None:
106
"""Saves image data to file."""
107
```
108
109
### Developer Tools
110
111
```python { .api }
112
def show_imgui_demo() -> None:
113
"""Shows the ImGui demo window for reference."""
114
115
def show_implot_demo() -> None:
116
"""Shows the ImPlot demo window for plotting reference."""
117
118
def show_item_debug() -> None:
119
"""Shows the item debugger window."""
120
121
def show_tool(tool: int) -> None:
122
"""Shows a specific developer tool."""
123
124
def show_demo() -> None:
125
"""Shows the DearPyGui demo window."""
126
```
127
128
### Data Storage
129
130
```python { .api }
131
def add_value_registry(*, tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
132
"""Creates a registry for storing values."""
133
134
def add_bool_value(*, default_value: bool = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
135
"""Creates a boolean value storage."""
136
137
def add_string_value(*, default_value: str = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
138
"""Creates a string value storage."""
139
140
def add_float_value(*, default_value: float = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
141
"""Creates a float value storage."""
142
143
def add_int_value(*, default_value: int = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
144
"""Creates an integer value storage."""
145
146
def add_color_value(*, default_value: Union[List[float], Tuple[float, ...]] = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
147
"""Creates a color value storage."""
148
```
149
150
### Clipboard and System
151
152
```python { .api }
153
def get_clipboard_text() -> str:
154
"""Gets text from the system clipboard."""
155
156
def set_clipboard_text(text: str) -> None:
157
"""Sets text to the system clipboard."""
158
159
def save_init_file(file: str) -> None:
160
"""Saves current configuration to initialization file."""
161
162
def output_frame_buffer(file: str) -> None:
163
"""Saves the current frame buffer to an image file."""
164
```
165
166
## Usage Examples
167
168
### Theming Example
169
170
```python
171
import dearpygui.dearpygui as dpg
172
173
# Create custom theme
174
with dpg.theme(tag="custom_theme"):
175
with dpg.theme_component(dpg.mvAll):
176
dpg.add_theme_color(dpg.mvThemeCol_Button, [100, 150, 200])
177
dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, [120, 170, 220])
178
dpg.add_theme_color(dpg.mvThemeCol_ButtonActive, [80, 130, 180])
179
dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 5)
180
181
with dpg.window(label="Themed Window", width=300, height=200):
182
dpg.add_text("This window uses a custom theme")
183
dpg.add_button(label="Themed Button")
184
185
# Apply theme to specific button
186
themed_button = dpg.add_button(label="Custom Themed Button")
187
dpg.bind_item_theme(themed_button, "custom_theme")
188
```
189
190
### File Dialog Example
191
192
```python
193
import dearpygui.dearpygui as dpg
194
195
def file_selected(sender, app_data):
196
selections = app_data['selections']
197
for file_path in selections.values():
198
print(f"Selected file: {file_path}")
199
200
def open_file_dialog():
201
dpg.show_item("file_dialog")
202
203
with dpg.window(label="File Dialog Example", width=400, height=200):
204
dpg.add_button(label="Open File", callback=open_file_dialog)
205
206
# Create file dialog (initially hidden)
207
with dpg.file_dialog(directory_selector=False, show=False,
208
callback=file_selected, tag="file_dialog",
209
width=700, height=400):
210
dpg.add_file_extension(".py", color=[0, 255, 0, 255])
211
dpg.add_file_extension(".txt", color=[255, 255, 0, 255])
212
dpg.add_file_extension(".*")
213
```
214
215
### Node Editor Example
216
217
```python
218
import dearpygui.dearpygui as dpg
219
220
def link_callback(sender, app_data):
221
dpg.add_node_link(app_data[0], app_data[1], parent=sender)
222
223
def delink_callback(sender, app_data):
224
dpg.delete_item(app_data)
225
226
with dpg.window(label="Node Editor", width=800, height=600):
227
228
with dpg.node_editor(callback=link_callback,
229
delink_callback=delink_callback):
230
231
with dpg.node(label="Node 1", pos=[20, 20]):
232
with dpg.node_attribute(label="Input"):
233
dpg.add_input_float(label="A", width=100)
234
with dpg.node_attribute(label="Output", attribute_type=dpg.mvNode_Attr_Output):
235
dpg.add_text("Result")
236
237
with dpg.node(label="Node 2", pos=[200, 100]):
238
with dpg.node_attribute(label="Input"):
239
dpg.add_input_float(label="B", width=100)
240
with dpg.node_attribute(label="Output", attribute_type=dpg.mvNode_Attr_Output):
241
dpg.add_text("Output")
242
```
243
244
### Resource Management Example
245
246
```python
247
import dearpygui.dearpygui as dpg
248
249
# Create registries
250
with dpg.texture_registry():
251
# Create texture from raw data
252
texture_data = []
253
for i in range(100 * 100):
254
texture_data.extend([1.0, 0.0, 1.0, 1.0]) # Magenta pixels
255
256
dpg.add_static_texture(width=100, height=100, default_value=texture_data, tag="my_texture")
257
258
with dpg.font_registry():
259
# Load custom font (if available)
260
try:
261
dpg.add_font("arial.ttf", 20, tag="custom_font")
262
except:
263
pass # Use default font
264
265
with dpg.window(label="Resources", width=300, height=200):
266
# Use texture in image
267
dpg.add_image("my_texture", width=50, height=50)
268
269
# Use font for text
270
if dpg.does_item_exist("custom_font"):
271
dpg.bind_font("custom_font")
272
dpg.add_text("Text with custom font")
273
```
274
275
## Constants
276
277
```python { .api }
278
# Node attribute types
279
mvNode_Attr_Input: int
280
mvNode_Attr_Output: int
281
mvNode_Attr_Static: int
282
283
# Node pin shapes
284
mvNode_PinShape_Circle: int
285
mvNode_PinShape_CircleFilled: int
286
mvNode_PinShape_Triangle: int
287
mvNode_PinShape_TriangleFilled: int
288
mvNode_PinShape_Quad: int
289
mvNode_PinShape_QuadFilled: int
290
291
# Theme colors
292
mvThemeCol_Text: int
293
mvThemeCol_TextDisabled: int
294
mvThemeCol_WindowBg: int
295
mvThemeCol_ChildBg: int
296
mvThemeCol_PopupBg: int
297
mvThemeCol_Border: int
298
mvThemeCol_BorderShadow: int
299
mvThemeCol_FrameBg: int
300
mvThemeCol_FrameBgHovered: int
301
mvThemeCol_FrameBgActive: int
302
mvThemeCol_TitleBg: int
303
mvThemeCol_TitleBgActive: int
304
mvThemeCol_TitleBgCollapsed: int
305
mvThemeCol_MenuBarBg: int
306
mvThemeCol_ScrollbarBg: int
307
mvThemeCol_ScrollbarGrab: int
308
mvThemeCol_ScrollbarGrabHovered: int
309
mvThemeCol_ScrollbarGrabActive: int
310
mvThemeCol_CheckMark: int
311
mvThemeCol_SliderGrab: int
312
mvThemeCol_SliderGrabActive: int
313
mvThemeCol_Button: int
314
mvThemeCol_ButtonHovered: int
315
mvThemeCol_ButtonActive: int
316
mvThemeCol_Header: int
317
mvThemeCol_HeaderHovered: int
318
mvThemeCol_HeaderActive: int
319
320
# Style variables
321
mvStyleVar_Alpha: int
322
mvStyleVar_WindowPadding: int
323
mvStyleVar_WindowRounding: int
324
mvStyleVar_WindowBorderSize: int
325
mvStyleVar_WindowMinSize: int
326
mvStyleVar_WindowTitleAlign: int
327
mvStyleVar_ChildRounding: int
328
mvStyleVar_ChildBorderSize: int
329
mvStyleVar_PopupRounding: int
330
mvStyleVar_PopupBorderSize: int
331
mvStyleVar_FramePadding: int
332
mvStyleVar_FrameRounding: int
333
mvStyleVar_FrameBorderSize: int
334
mvStyleVar_ItemSpacing: int
335
mvStyleVar_ItemInnerSpacing: int
336
mvStyleVar_IndentSpacing: int
337
mvStyleVar_CellPadding: int
338
mvStyleVar_ScrollbarSize: int
339
mvStyleVar_ScrollbarRounding: int
340
mvStyleVar_GrabMinSize: int
341
mvStyleVar_GrabRounding: int
342
mvStyleVar_TabRounding: int
343
mvStyleVar_ButtonTextAlign: int
344
mvStyleVar_SelectableTextAlign: int
345
```