DearPyGui
DearPyGui copied to clipboard
No callback for file dialog cancel button
Version of DearPyGui
Version: 1.3 Operating System: macOS 12.2.1 (M1 Pro)
My Issue/Question
According to the docs, a callback provided to dpg.file_dialog() "will be run when the file or directory picker is closed". However, it does not appear to run if the cancel button is clicked, and therefore there doesn't seem to be a way to find out if and when a user has clicked cancel in a file dialog.
To Reproduce
Steps to reproduce the behavior:
- Open a file dialog with a callback that includes a print
- Click cancel
- Note that the callback is not called
Expected behavior
Callback should be called (with app-data indicating that cancel was clicked).
Standalone, minimal, complete and verifiable example
from typing import Any
import dearpygui.dearpygui as dpg
dpg.create_context()
def _on_close(sender: int, app_data: Any, user_data: Any) -> None:
print('File dialog closed'). # does not print if cancel button clicked
def main() -> None:
with dpg.file_dialog(callback=_on_close, width=600, height=400):
dpg.add_file_extension(".txt")
dpg.create_viewport(title='File dialog callback bug', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
if __name__ == '__main__':
main()