forked from hoffstadt/DearPyGui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_deprecated.py
348 lines (292 loc) · 14.2 KB
/
_deprecated.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
def deprecated(reason):
string_types = (type(b''), type(u''))
if isinstance(reason, string_types):
def decorator(func1):
fmt1 = "Call to deprecated function {name} ({reason})."
@functools.wraps(func1)
def new_func1(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(
fmt1.format(name=func1.__name__, reason=reason),
category=DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning)
return func1(*args, **kwargs)
return new_func1
return decorator
elif inspect.isfunction(reason):
func2 = reason
fmt2 = "Call to deprecated function {name}."
@functools.wraps(func2)
def new_func2(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(
fmt2.format(name=func2.__name__),
category=DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning)
return func2(*args, **kwargs)
return new_func2
@deprecated("Use 'configure_app(docking=True, docking_space=dock_space)'.")
def enable_docking(dock_space=False):
""" deprecated function """
internal_dpg.configure_app(docking=True, docking_space=dock_space)
@deprecated("Use 'configure_app(init_file=file)'.")
def set_init_file(file="dpg.ini"):
""" deprecated function """
internal_dpg.configure_app(init_file=file)
@deprecated("Use 'configure_app(init_file=file, load_init_file=True)'.")
def load_init_file(file):
""" deprecated function """
internal_dpg.configure_app(init_file=file, load_init_file=True)
@deprecated("Use: `is_viewport_ok(...)`")
def is_viewport_created():
""" deprecated function """
return internal_dpg.is_viewport_ok()
@deprecated("Use: \ncreate_viewport()\nsetup_dearpygui()\nshow_viewport()")
def setup_viewport():
""" deprecated function """
internal_dpg.create_viewport()
internal_dpg.setup_dearpygui()
internal_dpg.show_viewport()
@deprecated("Use: `bind_item_theme(...)`")
def set_item_theme(item, theme):
""" deprecated function """
return internal_dpg.bind_item_theme(item, theme)
@deprecated("Use: `bind_item_type_disabled_theme(...)`")
def set_item_type_disabled_theme(item, theme):
""" deprecated function """
return internal_dpg.bind_item_type_disabled_theme(item, theme)
@deprecated("Use: `bind_item_type_theme(...)`")
def set_item_type_theme(item, theme):
""" deprecated function """
return internal_dpg.bind_item_type_theme(item, theme)
@deprecated("Use: `bind_item_font(...)`")
def set_item_font(item, font):
""" deprecated function """
return internal_dpg.bind_item_font(item, font)
@deprecated("Use: `add_item_activated_handler(...)`")
def add_activated_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_activated_handler(parent, **kwargs)
@deprecated("Use: `add_item_active_handler(...)`")
def add_active_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_active_handler(parent, **kwargs)
@deprecated("Use: `add_item_clicked_handler(...)`")
def add_clicked_handler(parent, button=-1, **kwargs):
""" deprecated function """
return internal_dpg.add_item_clicked_handler(parent, button, **kwargs)
@deprecated("Use: `add_item_deactived_after_edit_handler(...)`")
def add_deactivated_after_edit_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_deactivated_after_edit_handler(parent, **kwargs)
@deprecated("Use: `add_item_deactivated_handler(...)`")
def add_deactivated_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_deactivated_handler(parent, **kwargs)
@deprecated("Use: `add_item_edited_handler(...)`")
def add_edited_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_edited_handler(parent, **kwargs)
@deprecated("Use: `add_item_focus_handler(...)`")
def add_focus_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_focus_handler(parent, **kwargs)
@deprecated("Use: `add_item_hover_handler(...)`")
def add_hover_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_hover_handler(parent, **kwargs)
@deprecated("Use: `add_item_resize_handler(...)`")
def add_resize_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_resize_handler(parent, **kwargs)
@deprecated("Use: `add_item_toggled_open_handler(...)`")
def add_toggled_open_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_toggled_open_handler(parent, **kwargs)
@deprecated("Use: `add_item_visible_handler(...)`")
def add_visible_handler(parent, **kwargs):
""" deprecated function """
return internal_dpg.add_item_visible_handler(parent, **kwargs)
@deprecated("Use: `bind_colormap(...)`")
def set_colormap(item, source):
""" deprecated function """
return internal_dpg.bind_colormap(item, source)
@deprecated("Use: `bind_theme(0)`")
def reset_default_theme(item, source):
""" deprecated function """
return internal_dpg.bind_theme(item, source)
@deprecated
def set_staging_mode(mode):
""" deprecated function """
pass
@deprecated
def add_table_next_column(**kwargs):
""" deprecated function """
pass
@deprecated("Use: add_stage")
def add_staging_container(**kwargs):
""" deprecated function """
return internal_dpg.add_stage(**kwargs)
@deprecated("Use: stage")
@contextmanager
def staging_container(**kwargs):
"""
deprecated function
Args:
**label (str): Overrides 'name' as label.
**user_data (Any): User data for callbacks.
**use_internal_label (bool): Use generated internal label instead of user specified (appends ### uuid).
**id (Union[int, str]): Unique id used to programmatically refer to the item.If label is unused this will be the label.
Yields:
Union[int, str]
"""
try:
warnings.warn("'staging_container' is deprecated and was changed to 'stage'", DeprecationWarning, 2)
widget = internal_dpg.add_stage_container(**kwargs)
internal_dpg.push_container_stack(widget)
yield widget
finally:
internal_dpg.pop_container_stack()
@deprecated("Use: add_spacer(...)")
def add_spacing(**kwargs):
""" (deprecated function) Adds vertical spacing.
Args:
label (str, optional): Overrides 'name' as label.
user_data (Any, optional): User data for callbacks.
use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid).
tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label.
indent (int, optional): Offsets the widget to the right the specified number multiplied by the indent style.
parent (Union[int, str], optional): Parent to add this item to. (runtime adding)
before (Union[int, str], optional): This item will be displayed before the specified item in the parent.
show (bool, optional): Attempt to render widget.
pos (Union[List[int], Tuple[int]], optional): Places the item relative to window coordinates, [0,0] is top left.
count (int, optional): Number of spacings to add the size is dependant on the curret style.
Returns:
Union[int, str]
"""
if 'count' in kwargs.keys():
count = kwargs["count"]
kwargs.pop("count", None)
internal_dpg.add_group(**kwargs)
internal_dpg.push_container_stack(internal_dpg.last_container())
for i in range(count):
internal_dpg.add_spacer()
result_id = internal_dpg.pop_container_stack()
else:
result_id = internal_dpg.add_spacer(**kwargs)
return result_id
@deprecated("Use: add_spacer(...)")
def add_dummy(**kwargs):
""" (deprecated function) Adds a spacer or 'dummy' object.
Args:
label (str, optional): Overrides 'name' as label.
user_data (Any, optional): User data for callbacks.
use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid).
tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label.
width (int, optional): Width of the item.
height (int, optional): Height of the item.
indent (int, optional): Offsets the widget to the right the specified number multiplied by the indent style.
parent (Union[int, str], optional): Parent to add this item to. (runtime adding)
before (Union[int, str], optional): This item will be displayed before the specified item in the parent.
show (bool, optional): Attempt to render widget.
pos (Union[List[int], Tuple[int]], optional): Places the item relative to window coordinates, [0,0] is top left.
Returns:
Union[int, str]
"""
return internal_dpg.add_spacer(**kwargs)
@deprecated("Use: `destroy_context()`")
def cleanup_dearpygui():
""" deprecated function """
return internal_dpg.destroy_context()
@deprecated("Use: group(horizontal=True)")
def add_same_line(**kwargs):
""" deprecated function """
last_item = internal_dpg.last_item()
group = internal_dpg.add_group(horizontal=True, **kwargs)
internal_dpg.move_item(last_item, parent=group)
internal_dpg.capture_next_item(lambda s: internal_dpg.move_item(s, parent=group))
return group
@deprecated("Use: `add_child_window()`")
def add_child(**kwargs):
""" (deprecated function) Adds an embedded child window. Will show scrollbars when items do not fit.
Args:
label (str, optional): Overrides 'name' as label.
user_data (Any, optional): User data for callbacks
use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid).
tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label.
width (int, optional): Width of the item.
height (int, optional): Height of the item.
indent (int, optional): Offsets the widget to the right the specified number multiplied by the indent style.
parent (Union[int, str], optional): Parent to add this item to. (runtime adding)
before (Union[int, str], optional): This item will be displayed before the specified item in the parent.
payload_type (str, optional): Sender string type must be the same as the target for the target to run the payload_callback.
drop_callback (Callable, optional): Registers a drop callback for drag and drop.
show (bool, optional): Attempt to render widget.
pos (Union[List[int], Tuple[int]], optional): Places the item relative to window coordinates, [0,0] is top left.
filter_key (str, optional): Used by filter widget.
delay_search (bool, optional): Delays searching container for specified items until the end of the app. Possible optimization when a container has many children that are not accessed often.
tracked (bool, optional): Scroll tracking
track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom
border (bool, optional): Shows/Hides the border around the sides.
autosize_x (bool, optional): Autosize the window to its parents size in x.
autosize_y (bool, optional): Autosize the window to its parents size in y.
no_scrollbar (bool, optional): Disable scrollbars (window can still scroll with mouse or programmatically).
horizontal_scrollbar (bool, optional): Allow horizontal scrollbar to appear (off by default).
menubar (bool, optional): Shows/Hides the menubar at the top.
Returns:
Union[int, str]
"""
return internal_dpg.add_child_window(**kwargs)
@deprecated("Use: `child_window()`")
@contextmanager
def child(**kwargs):
""" (deprecated function) Adds an embedded child window. Will show scrollbars when items do not fit.
Args:
label (str, optional): Overrides 'name' as label.
user_data (Any, optional): User data for callbacks
use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid).
tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label.
width (int, optional): Width of the item.
height (int, optional): Height of the item.
indent (int, optional): Offsets the widget to the right the specified number multiplied by the indent style.
parent (Union[int, str], optional): Parent to add this item to. (runtime adding)
before (Union[int, str], optional): This item will be displayed before the specified item in the parent.
payload_type (str, optional): Sender string type must be the same as the target for the target to run the payload_callback.
drop_callback (Callable, optional): Registers a drop callback for drag and drop.
show (bool, optional): Attempt to render widget.
pos (Union[List[int], Tuple[int]], optional): Places the item relative to window coordinates, [0,0] is top left.
filter_key (str, optional): Used by filter widget.
delay_search (bool, optional): Delays searching container for specified items until the end of the app. Possible optimization when a container has many children that are not accessed often.
tracked (bool, optional): Scroll tracking
track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom
border (bool, optional): Shows/Hides the border around the sides.
autosize_x (bool, optional): Autosize the window to its parents size in x.
autosize_y (bool, optional): Autosize the window to its parents size in y.
no_scrollbar (bool, optional): Disable scrollbars (window can still scroll with mouse or programmatically).
horizontal_scrollbar (bool, optional): Allow horizontal scrollbar to appear (off by default).
menubar (bool, optional): Shows/Hides the menubar at the top.
Yields:
Union[int, str]
"""
try:
widget = internal_dpg.add_child_window(**kwargs)
internal_dpg.push_container_stack(widget)
yield widget
finally:
internal_dpg.pop_container_stack()
@deprecated("Use: Just not recommended")
def setup_registries() -> None:
"""Adds default registries for fonts, handlers, textures, colormaps, and values."""
internal_dpg.add_font_registry(tag=internal_dpg.mvReservedUUID_0)
internal_dpg.add_handler_registry(tag=internal_dpg.mvReservedUUID_1)
internal_dpg.add_texture_registry(tag=internal_dpg.mvReservedUUID_2)
internal_dpg.add_value_registry(tag=internal_dpg.mvReservedUUID_3)
internal_dpg.add_colormap_registry(tag=internal_dpg.mvReservedUUID_4)
@deprecated("Use: `set_frame_callback()`")
def set_start_callback(callback):
""" deprecated function """
return internal_dpg.set_frame_callback(3, callback)