hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
12.63k stars 669 forks source link

DPG file_dialog does not produce correct file_path #2213

Closed voryzen closed 6 months ago

voryzen commented 8 months ago

Thank you!


Version of Dear PyGui

Version: 1.10.0 Operating System: Arch Linux

My Issue/Question

When using a file dialog widget, as a directory selector (not file selector, as far as I can tell), the SELECTION dictionary returned is erroneous; if the selected folder is displayed in the input box of said file dialog widget, then the last folder in the directory path is doubled/repeated.

Maybe the key is being added to the end of the path? or the contents of the input box is beeing added onto the path. Those are my best guesses.

To Reproduce

Steps to reproduce the behavior:

  1. Use my code below, install dpg as required
  2. Run issue.py and click on 'open dialog'
  3. look at terminal output

Expected behavior

The last folder in the directory path is not repeated/doubled

Screenshots/Video

Peek 2023-10-31 14-05

Standalone, minimal, complete and verifiable example

## OhDearPyGui ##
import dearpygui.dearpygui as dpg

## Main code ##

dpg.create_context()
dpg.create_viewport(title='Testing for Issues, :(', width=800, height=600)
dpg.set_viewport_min_height(300)
dpg.set_viewport_min_width(500)

###############

def choose_ok(sender, app_data):
## Shouldn't add the key (i'm assuming) onto the already complete path

    for key in app_data["selections"]:
        print("This is the key")
        print(key)
        print("This is the path")
        print(app_data["selections"][key])
        print("")
        print("")
        print("")
        print("The key isn't added on to the path?")
        print("")
        print("make sure the folder name is contained")
        print("within the directory path input box on")
        print("the dialog box then try again")

def choose_cancel(sender, app_data):
    dpg.configure_item("repoChoose_dialog", show=False)

###############

## PRIMARY WINDOW ##
with dpg.window(tag="primary_window", no_saved_settings=True, no_title_bar=True, no_move=True):

    ## SMALLER WINDOW ##
    with dpg.window(label="TEST THIS ISSUE", tag="testing_window", pos=[5,5], show=True):

        with dpg.table(tag="issue_header", header_row=False, resizable=False, policy=dpg.mvTable_SizingStretchProp,
                   borders_outerH=False, borders_innerV=False, borders_innerH=False, borders_outerV=False):

            dpg.add_table_column()

            with dpg.table_row():
                dpg.add_button(label="open dialog", tag="dialog_btn", show=True, callback=lambda: dpg.show_item("choose_dialog"))

    ## ADD FILE DIALOG WINDOW ##
    with dpg.window(tag="test_file_window", pos=[5,5], show=False):

        dpg.add_file_dialog(label="Select a config file", tag="choose_dialog", directory_selector=True, file_count = 1, show=False, modal=True, callback=choose_ok, cancel_callback=choose_cancel, width=700 ,height=400)

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.set_primary_window("primary_window", True)
while dpg.is_dearpygui_running():
    dpg.render_dearpygui_frame()
dpg.destroy_context()
v-ein commented 7 months ago

This appears to be a duplicate of #1942. I'd suggest that this ticket be closed and #1942 left open for future work on the issue.

voryzen commented 6 months ago

This appears to be a duplicate of #1942. I'd suggest that this ticket be closed and #1942 left open for future work on the issue.