rio-labs / rio

WebApps in pure Python. No JavaScript, HTML and CSS needed
https://rio.dev
Apache License 2.0
1.98k stars 68 forks source link

[Feature Request] Support pywebview's Open File Dialog feature #178

Open iwr-redmond opened 1 week ago

iwr-redmond commented 1 week ago

Description

The app mode window (pywebview) requires additional configuration to allow uploads, similar to the code already present in session.py's save_file function.

Suggested Solution

Implement the webview.OPEN_DIALOG feature in session.py's file_chooser function. Optionally, you can integrate the webview.dom.documents.events class for drag and drop support in app mode.

Alternatives

Nil

Additional Context

No response

Related Issues/Pull Requests

No response

mad-moo commented 1 week ago

Just to be clear, you aren't asking for a change in behavior, but want the file picker to bypass the file upload and use the file's path instead?

iwr-redmond commented 6 days ago

Yes, with the addition of a native file dialog that can be accessed by clicking on the drag and drop area (or, I suppose, a button if preferred when setting up the component) if Rio is running in app mode. See Flet's demo for something similar. Unlike Flet, which relies on third party components for its native file picker, pywebview uses Pyside/QT and would therefore be consistent across all desktop platforms.

I see that Drag and Drop has been added to the file picker code in the last few days, so adding the corresponding pywebview enabling code to make this work in app mode would also be helpful.