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

How can I set the input of add_input_text() to be the result of file_dialog()? #2130

Closed joybio closed 7 months ago

joybio commented 12 months ago

import dearpygui.dearpygui as dpg curPath = os.path.abspath(os.path.dirname(file))

dpg.add_text("Output:", label="Label", show_label=False) with dpg.group(horizontal=True): dpg.add_input_text(hint="Enter output here", default_value="DPrime.out.xls", callback=_log) with dpg.file_dialog(label=curPath, width=600, height=400, show=False, callback=lambda s, a, u: print(s, a, u)): dpg.add_file_extension(".*", color=(255, 255, 255, 255)) dpg.add_button(label="Open", user_data=dpg.last_container(), callback=lambda s, a, u: dpg.configure_item(u, show=True))

I want to set the add_input_text() as the file_dialog()? how to make it?

joybio commented 12 months ago

I have successfully resolved the initial issue with the package, and it is indeed an excellent package. However, I have encountered another problem. Whenever I select a file from the file_dialog, the child window closes unexpectedly. I am seeking guidance on how to keep the window open after selecting a file, but didn't find clues, can you help me?

cartazio commented 11 months ago

How did you set the input_text box? i've been struggling to figure out that myself

cartazio commented 11 months ago

nvm, i needed to use the tag system

joybio commented 11 months ago

@cartazio I just add a "tag" in add_input_text(), and use the "callback" in add_buton() to revise the value of "tag". for example:

def DPrime_select_directory(sender, app_data): with dpg.file_dialog(directory_selector=False, show=True, width=600, height=400, callback=DPrime_select_file): dpg.add_file_extension(".msa", color=(255, 0, 255, 255), custom_text="header")

def DPrime_select_file(sender, app_data): file = app_data["file_path_name"] Current_path = app_data["current_path"] dpg.set_value(item="DPrime_input", value=file)

dpg.add_input_text(hint="Enter Multiple alignment file here", width=400, tag="DPrime_input") dpg.add_button(label="...", callback=DPrime_select_directory)

v-ein commented 7 months ago

@joybio did I get it right that your problem has been solved? If so, would you please close this ticket?

joybio commented 7 months ago

Oh, yes. My problem had been solved. Great DearPyGui ! Thanks for your work ! I'll close it on next Monday.

---- Replied Message ---- | From | Vladimir @.> | | Date | 12/02/2023 04:31 | | To | @.> | | Cc | Junbo @.>@.> | | Subject | Re: [hoffstadt/DearPyGui] How can I set the input of add_input_text() to be the result of file_dialog()? (Issue #2130) |

@joybio did I get it right that your problem has been solved? If so, would you please close this ticket?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>