Files
playground/ui_prompts.py
T
2023-02-18 07:39:08 +01:00

23 lines
553 B
Python

import webview
from webview import Window
def webview_file_dialog():
def open_file_dialog(w: Window):
try:
return w.create_file_dialog(webview.FOLDER_DIALOG)[0]
except TypeError:
pass # user exited file dialog without picking
finally:
w.hide()
w.destroy()
window = webview.create_window("", hidden=True)
webview.start(open_file_dialog, window)
# file will either be a string or None
return file
if __name__ == "__main__":
print(webview_file_dialog())