hoffstadt / hoffstadt/DearPyGui

SystemError with dpg.file_dialog

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

Description

DearPyGUI version: 1.11.1
Python version: 3.10
Operating System: Ubuntu 22.04

I'm seeing the same error as in discussion #1609 using the `file_dialog`. Using the code below, the error occurs on subsequent launches of the file dialog (not on the first launch). The error message made me suspect the issue related to using a tag for the `file_dialog`. Indeed, when remove the tag from the code, the error is avoided. Maybe using a tag for a dialog is not recommended, but I got in the habit of tagging all UI elements. In any case, hope this helps narrow down the bug.

## To Reproduce

Steps to reproduce the behavior:
1. Launch the MRE code included below
2. Click on the 'Load' button.
3. Select a file or cancel, doesn't matter. Just get the dialog to go away.
4. Click the 'Load' button a 2nd time.
5. Kablamo! Error occurs

## Expected behavior

I expect no kablamos using the file dialog.

## Standalone, minimal, complete and verifiable example

```python
import dearpygui.dearpygui as dpg

def choose_file():
with dpg.file_dialog(
tag='file_selector', # <-- causes SystemError
width=700,
height=500,
show=True
):
dpg.add_file_extension(".*", color=(31, 31, 127, 255))

dpg.create_context()
dpg.create_viewport(title='File dialog crash app', width=900, height=600)

with dpg.window(tag="main_win", no_title_bar=True):
dpg.add_button(label="Load", callback=choose_file)

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.set_primary_window('main_win', True)
dpg.start_dearpygui()
dpg.destroy_context()
```

## Traceback

```
Traceback (most recent call last):
File "...venv/lib/python3.10/site-packages/dearpygui/dearpygui.py", line 1816, in file_dialog
widget = internal_dpg.add_file_dialog(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, callback=callback, show=show, default_path=default_path, default_filename=default_filename, file_count=file_count, modal=modal, directory_selector=directory_selector, min_size=min_size, max_size=max_size, cancel_callback=cancel_callback, **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 "...debug_file_dialog_crash.py", line 5, in choose_file
with dpg.file_dialog(
File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "...venv/lib/python3.10/site-packages/dearpygui/dearpygui.py", line 1820, in file_dialog
internal_dpg.pop_container_stack()
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.