hoffstadt / hoffstadt/DearPyGui

dearpygui.dearpygui.window tag parameter must be > 0

Open
#2,507 5 comments 0 reactions 0 assignees View on GitHub
state: pending type: docs
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

The current documentation for window has the following for the tag parameter:

`tag (Union[int, str], optional) – Unique id used to programmatically refer to the item.If label is unused this will be the label.`

https://dearpygui.readthedocs.io/en/latest/reference/dearpygui.html#dearpygui.dearpygui.window

**My Improvement**

`tag (Union[int, str], optional) – Unique id used to programmatically refer to the item. If label is unused this will be the label. If using an integer, it must be greater than 0.`

**Necessary Assets**

The following code works as expected.

```python
import dearpygui.dearpygui as dpg

dpg.create_context()

with dpg.window(tag=1):
dpg.add_text("Hello, world")
dpg.add_button(label="Save")
dpg.add_input_text(label="string", default_value="Quick brown fox")
dpg.add_slider_float(label="float", default_value=0.273, max_value=1)

dpg.create_viewport(title='Custom Title', width=600, height=200)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.set_primary_window(1, True)
dpg.start_dearpygui()
dpg.destroy_context()
```

Setting tag to -1 will result in the following error:
```
OverflowError: can't convert negative int to unsigned

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/alex/py313/lib/python3.13/site-packages/dearpygui/dearpygui.py", line 2969, in window
widget = internal_dpg.add_window(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, show=show, pos=pos, delay_search=delay_search, min_size=min_size, max_size=max_size, menubar=menubar, collapsed=collapsed, autosize=autosize, no_resize=no_resize, unsaved_document=unsaved_document, no_title_bar=no_title_bar, no_move=no_move, no_scrollbar=no_scrollbar, no_collapse=no_collapse, horizontal_scrollbar=horizontal_scrollbar, no_focus_on_appearing=no_focus_on_appearing, no_bring_to_front_on_focus=no_bring_to_front_on_focus, no_close=no_close, no_background=no_background, modal=modal, popup=popup, no_saved_settings=no_saved_settings, no_open_over_existing_popup=no_open_over_existing_popup, no_scroll_with_mouse=no_scroll_with_mouse, on_close=on_close, **kwargs)
SystemError: returned a result with an exception set

During handling of the above exception, another exception occurred:

Exception: Error: [1009] Message: No container to pop.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/alex/source/gui-test/test.py", line 5, in
with dpg.window(tag=-1):
~~~~~~~~~~^^^^^^^^
File "/usr/lib/python3.13/contextlib.py", line 141, in __enter__
return next(self.gen)
File "/home/alex/py313/lib/python3.13/site-packages/dearpygui/dearpygui.py", line 2973, in window
internal_dpg.pop_container_stack()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
SystemError: returned a result with an exception set
```

Setting tag to 0 will result in the following error:

```
Exception:
Error: [1005]
Command: set_primary_window
Item: 0
Label: Not found
Item Type: Unknown
Message: Item not found: 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/alex/source/gui-test/test.py", line 14, in
dpg.set_primary_window(0, True)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/home/alex/py313/lib/python3.13/site-packages/dearpygui/dearpygui.py", line 9523, in set_primary_window
return internal_dpg.set_primary_window(window, value, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: returned a result with an exception set
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.