flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.61k stars 455 forks source link

ft.FilePicker does not work on some Linux distros like KDE #3296

Open redromnon opened 6 months ago

redromnon commented 6 months ago

Description

Looks to me like the FilePicker component works on GNOME (tested on Pop OS 22.04 and Ubuntu 24.04) and opens up the native folder application to select a folder. But it doesn't do anything on KDE Plasma 5 and 6 (Tested on Kubuntu 24.04 and Arch Linux).

Code example to reproduce the issue:

folder_picker = ft.FilePicker(on_result=folder_dialog_result)

select_folder_icon = ft.IconButton(
        icon=ft.icons.FOLDER_ROUNDED, tooltip="Select folder location", 
        on_click=lambda e: folder_picker.get_directory_path()
)

def folder_dialog_result(self, e: ft.FilePickerResultEvent):

    print(e.path)

page.add(folder_picker)
page.add(select_folder_icon)

Describe the results you received:

Nothing happens after I click the folder icon. Got this error in journalctl when I clicked on the folder icon:

xdp-kde-settings: Namespace  "org.gnome.desktop.interface"  is not supported

Describe the results you expected: The native folder app should open and allow me to select a folder.

Additional information you deem important (e.g. issue happens only occasionally): None

Flet version (pip show flet):

Version: 0.19.0

Operating system: Kubuntu 24.04 LTS

Additional environment details: KDE Plasma Version: 5.27.11 KDE Frameworks Version 5.115.0 Qt Version: 5.15.13 Graphics Platform: X11

vindevoy commented 6 months ago

This is not because of the distribution, in your case Kubuntu. Kubuntu, with default KDE installed, also has the possibility to install the Gnome libraries.

See this article, for example: https://www.reddit.com/r/Ubuntu/comments/m8q1qz/how_do_i_get_gnome_on_kubuntu/

So basically, when you install gnome via "apt install gnome" or "sudo apt install gnome" according to your rights on the system, you will be able to run the application and use the file picker.

redromnon commented 6 months ago

Thanks for responding.

Basically, Flet will only work with GNOME File Picker and not with any other DE File Picker?

sidviny commented 6 months ago

Looking at the class it seems to be missing, no. At least, that's how I see it, but it's up to others who wrote the code to tell you exactly.

redromnon commented 6 months ago

I believe Flet internally uses Flutter packages. @sidviny Are you referring to the Dart or the Python side of this module's implementation?

redromnon commented 6 months ago

The Flet docs also mention installing zenity as a pre-requisite for File Picker to work. If I run zenity --file-selection on Kubuntu, it works just fine.