DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

set_value() to a button in a file_dilaog callback doesn't work

Open chesterrc opened this issue 11 months ago • 3 comments

Version of Dear PyGui

Version: 1.11.1 Operating System: Windows 10

My Issue/Question

When I try to use set_value() to a button within a callback for a file_dialog(), the button's value is not set.

To Reproduce

Steps to reproduce the behavior:

  1. Create a button
  2. Create a hidden file_dialog window
  3. Create a file_select function with the arguments of sender and app_data to set the value of the button to app_data["file_path_name"] then print the get_value of the button
  4. Set a callback on the button to show file_dialog window
  5. Set the file_dialog function as the callback to the file_dialog
  6. Run the python script, click the button, select a file, and check on the print statements.

Expected behavior

The print statement will have an output of "None"

Screenshots/Video

dearpygui_issue

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg


def file_select(sender, app_data):
    print(app_data)
    dpg.set_value("button", app_data["file_path_name"])
    print(dpg.get_value("button"))


dpg.create_context()
dpg.create_viewport(title='Test For Set Value', width=600, height=200)
dpg.setup_dearpygui()

with dpg.window(label="Test"):
    dpg.add_button(
                    label="button",
                    tag="button",
                    callback=lambda: dpg.show_item("file_dialog")
                    )

with dpg.file_dialog(show=False, label="choose a file",
                    tag="file_dialog", callback=file_select):
    dpg.add_file_extension(".*")


dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

chesterrc avatar Nov 17 '24 17:11 chesterrc