Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document FilePicker Platform-Compatibility-Matrix #3295

Open
lbedner opened this issue May 15, 2024 · 4 comments
Open

Document FilePicker Platform-Compatibility-Matrix #3295

lbedner opened this issue May 15, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@lbedner
Copy link

lbedner commented May 15, 2024

Description

ft.FilePicker.get_directory_path() is not working for me when running the application in web app mode.

Code example to reproduce the issue:

import flet as ft


def main(page: ft.Page):
    def pick_directory_result(e: ft.FilePickerResultEvent):
        if e.path:
            selected_directory = e.path
            page.add(ft.Text(f"Selected directory: {selected_directory}"))
        else:
            page.add(ft.Text("No directory selected"))

    def pick_file_result(e: ft.FilePickerResultEvent):
        if e.files:
            selected_files = ", ".join(f.name for f in e.files)
            page.add(ft.Text(f"Selected file(s): {selected_files}"))
        else:
            page.add(ft.Text("No file selected"))

    # Create a FilePicker to select directories
    directory_picker = ft.FilePicker(on_result=pick_directory_result)

    # Create a FilePicker to select files
    file_picker = ft.FilePicker(on_result=pick_file_result)

    # Add a button to trigger the directory selection
    pick_directory_button = ft.ElevatedButton(
        text="Select Directory",
        on_click=lambda _: directory_picker.get_directory_path(),
    )

    # Add a button to trigger the file selection
    pick_file_button = ft.ElevatedButton(
        text="Select File",
        on_click=lambda _: file_picker.pick_files(),
    )

    # Add controls to the page
    page.add(pick_directory_button, directory_picker, pick_file_button, file_picker)


ft.app(target=main)

Describe the results you received:

Running in normal mode

leonardbedner@MacBook-Pro ~/W/P/ee-toolset (dockerize-app)> flet run flet_folder_test.py

flet_folder_test_local

Running in web app mode

leonardbedner@MacBook-Pro ~/W/P/ee-toolset (dockerize-app)> flet run flet_folder_test.py --web --port 8081

flet_folder_test_web

Describe the results you expected:

I expect to be able to both select files and folders in normal and web app modes.

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

Flet version (pip show flet):

Name: flet
Version: 0.22.0
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page:
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: /Users/leonardbedner/.virtualenvs/ee_toolset/lib/python3.11/site-packages
Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog
Required-by: ee-toolset

Give your requirements.txt file (don't pip freeze, instead give direct packages):

I'm using poetry...

[tool.poetry]
name = "ee-toolset"
version = "0.1.0"
description = "Eternity Engine Toolset"
authors = ["lbedner"]
readme = "README.md"
packages = [{include = "app"}]

[tool.poetry.dependencies]
python = "^3.10"
aiohttp = ">=3.8.6"
bs4 = "^0.0.1"
chromadb = "^0.4.18"
flet = "v0.22.0"
gitpython = "^3.1.40"
icecream = "^2.1.3"
langchain = "^0.1.6"
langchainhub = "^0.1.14"
openai = "^1.3.5"
pdfplumber = "^0.10.3"
psycopg2-binary = "^2.9.9"
pydantic-settings = "^2.1.0"
python-docx = "^1.1.0"
structlog = "^23.2.0"
tiktoken = "^0.5.1"
unstructured = "^0.11.0"
pyperclip = "^1.8.2"
sqlmodel = "0.0.16"
requests = "^2.31.0"
types-requests = "^2.31.0.20240125"
pyodbc = "^5.1.0"
youtube-transcript-api = "^0.6.2"
pytube = "^15.0.0"
isodate = "^0.6.1"
pygithub = "^2.3.0"
langsmith = "^0.1.54"


[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
black = "^23.11.0"
pre-commit = "^3.5.0"
tox = "^4.11.4"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
norecursedirs = ["data"]

Operating system:

macOS Sonoma 14.2.1

Additional environment details:

@ndonkoHenri
Copy link
Collaborator

That method is supported on all platforms except the web platform.

We need to document this.

@ndonkoHenri ndonkoHenri added the documentation Improvements or additions to documentation label May 16, 2024
@ndonkoHenri ndonkoHenri changed the title ft.FilePicker.get_directory_path() Not Working In Web App Mode Document FilePicker Platform-Compatibility-Matrix May 16, 2024
@zshnrg
Copy link

zshnrg commented May 17, 2024

That method is supported on all platforms except the web platform.

We need to document this.

Do you have any workaround so that we can send users a file that they can download, but the file is sent in bytes instead of the file URL in the directory?

@ndonkoHenri
Copy link
Collaborator

You could convert the bytes to an actual file, then use this.

@lbedner
Copy link
Author

lbedner commented May 17, 2024

That method is supported on all platforms except the web platform.

We need to document this.

Any suggestions for workaround for this on Web? I know I read somewhere something about Flutter 3rd party packages being a thing (either now, or in the future) 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants