1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] dearpygui and Dialog Popup

Discussão em 'Python' iniciado por Stack, Novembro 30, 2025.

  1. Stack

    Stack Membro Participativo

    I want to show a popup dialog (for example, to warn the user about a duplicate file) in response to any callback—in this case, after selecting a file (or canceling) in a file dialog opened from a button in a tab. The popup must appear automatically. I am using a dpg.window(modal=True, show=False) as a modal dialog for popups. This is the method recommended by DearPyGui for dialogs, alerts, and any UI that needs to be triggered programmatically from callbacks. however I cannot get the popup to appear. I have tried asking a LLM chatbot for help but it was a waste of time. below is a minimal example of the problem, it is following the general structure of my program.


    import dearpygui.dearpygui as dpg

    def choose_csv_callback():
    dpg.configure_item("file_dialog", show=True)
    dpg.set_item_user_data("file_dialog", "csv_file")

    def file_dialog_callback(sender, app_data, user_data):
    dpg.set_value("duplicate_file_popup_text", "Popup ALWAYS appears.")
    dpg.configure_item("duplicate_file_popup", show=True)

    dpg.create_context()

    with dpg.window(tag="Primary Window"):
    with dpg.tab_bar():
    with dpg.tab(label="Import"):
    dpg.add_button(label="Choose CSV", callback=choose_csv_callback)
    with dpg.file_dialog(
    label="CSV File Dialog", width=600, height=400, show=False,
    callback=file_dialog_callback,
    tag="file_dialog",
    modal=True,
    ):
    dpg.add_file_extension(".csv", color=(0, 255, 0, 255))
    dpg.add_file_extension(".*", color=(180, 180, 180, 255))

    # Modal popup window, always at root level
    with dpg.window(
    tag="duplicate_file_popup",
    modal=True,
    no_title_bar=True,
    show=False,
    width=400,
    height=100,
    pos=[200, 150]
    ):
    dpg.add_text("", tag="duplicate_file_popup_text")
    dpg.add_button(
    label="OK",
    callback=lambda: dpg.configure_item("duplicate_file_popup", show=False)
    )

    dpg.create_viewport(title="Minimal Tab/FileDialog/Popup", width=700, height=400)
    dpg.setup_dearpygui()
    dpg.show_viewport()
    dpg.set_primary_window("Primary Window", True)
    dpg.start_dearpygui()
    dpg.destroy_context()

    Thanks for your time. and if i didnt explain something just tell me :)

    Continue reading...

Compartilhe esta Página