Message box after a file dialog #2125
-
Hi, I found how to make a message box: #1308 How can I verify some condition in the callback of the file dialog, and possibly show an error message box? When I call show_info() in the file dialog's callback, nothing shows. Thank you! Example: import dearpygui.dearpygui as dpg
from dwi_ml.gui.utils.gui_popup_message import show_info
# ---------
# Prepare callbacks
# ---------
def on_selection(sender, unused, user_data):
if user_data[1]:
print("User selected 'Ok'")
else:
print("User selected 'Cancel'")
# delete window
dpg.delete_item(user_data[0])
def verify_and_show_popup(sender, app_data, user_data):
if True: # I will verify some condition
show_info("TITLE", "Some message", on_selection)
# ---------
# Prepare buttons and show:
# ---------
dpg.create_context()
dpg.create_viewport(title='Welcome', width=1300, height=800)
dpg.setup_dearpygui()
dpg.add_file_dialog(
directory_selector=True, tag="my_file_dialog", show=False, modal=True,
file_count=1, callback=verify_and_show_popup)
with dpg.window(tag="Primary Window"):
dpg.add_button(label="THIS BUTTON WORKS!",
callback=verify_and_show_popup,)
dpg.add_button(label="OPENS FILE DIALOG BUT OK CLICK DOES NOT POP UP MESSAGE",
callback=lambda: dpg.show_item("my_file_dialog"))
dpg.show_viewport()
dpg.set_primary_window("Primary Window", True)
dpg.start_dearpygui()
dpg.destroy_context() |
Beta Was this translation helpful? Give feedback.
Answered by
EmmaRenauld
Jul 3, 2023
Replies: 1 comment
-
Found it! I can add |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
EmmaRenauld
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found it! I can add
no_open_over_existing_popup=False
in the window creation in show_info :)