dearpygui.dearpygui.window tag parameter must be > 0

Open
#2,507 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
documentation

Research direction

Start at the linked Dear PyGui reference documentation page and locate the window tag parameter description. Update it to state that integer tags must be greater than 0, then verify that the rendered documentation shows the revised wording.

Written by the indexing model from the issue text.

Description

state: pending type: docs

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.

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: <built-in function add_window> 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 <module>
    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: <built-in function pop_container_stack> 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 <module>
    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: <built-in function set_primary_window> returned a result with an exception set
Dominant language
C++
Stars
15.7k
Forks
790
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hoffstadt/DearPyGui

All issues in hoffstadt/DearPyGui

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.