hoffstadt / hoffstadt/DearPyGui

File Dialog Callback Data is Confusing

Open
#1,491 2 comments 1 reaction 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

Version: dearpygui 1.1.3
Operating System: Windows 10

## My Issue/Question

File Dialog call back `app_data` is confusing. When one file is selected the `app_data` dict contains an incorrect filename, it includes the filter as the extension.
The `file_path_name` also contains the filter as the extension.

When multiple files are selected, the `file_name` and `file_path_name` also append the filter but it makes no sense (see output below)

```
app_data with one file selected:
{'current_filter': '.*',
'current_path': 'C:\\Users\\igor\\Desktop\\dearpygui',
'file_name': 'out.*',
'file_path_name': 'C:\\Users\\igor\\Desktop\\dearpygui\\out.*',
'selections': {'out.csv': 'C:\\Users\\igor\\Desktop\\dearpygui\\out.csv'}}
```
```
app_data with two files selected:
{'current_filter': '.*',
'current_path': 'C:\\Users\\igor\\Desktop\\dearpygui',
'file_name': '2 files Selected.*',
'file_path_name': 'C:\\Users\\igor\\Desktop\\dearpygui\\2 files Selected.*',
'selections': {'main.py': 'C:\\Users\\igor\\Desktop\\dearpygui\\main.py',
'out.csv': 'C:\\Users\\igor\\Desktop\\dearpygui\\out.csv'}}
```

## Expected behavior
`file_name` should be the exact filename, `file_path_name` should be a list of paths (or something? not sure how useful it is given the `selections` dict.)

The selections dict can also leverage pathlib objects for additional flexibility

## Standalone, minimal, complete and verifiable example

```python
import dearpygui.dearpygui as dpg

dpg.create_context()

def callback(sender, app_data):
print("Sender: ", sender)
print("App Data: ", app_data)

with dpg.file_dialog(directory_selector=False, show=False,
callback=callback,
height=300,
width=600,
tag="file_dialog_id") as file_dialog:

dpg.add_file_extension(".*")

with dpg.window(label="Tutorial", width=800, height=300):
dpg.add_button(label="Directory Selector", callback=lambda: dpg.show_item("file_dialog_id"))
print (dpg.get_item_configuration(file_dialog))

dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
```

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.