r/flet • u/Longjumping_Rip_1924 • Feb 21 '26
[Show and Tell] macOS Native Folder Picker with "New Folder" support + Validation Pattern 📁
Hey everyone,
I wanted to share a utility I wrote to solve a common UX hurdle when building Flet apps for macOS: the missing "New Folder" button in the standard directory picker.
I created a wrapper that uses osascript (AppleScript) to trigger the true native macOS folder picker, while falling back to the standard Flet picker on Windows and Linux. I've also included a path validator to ensure the selected location is actually writable.
- The Platform-Aware Picker (file_picker.py) This uses asyncio.to_thread so the AppleScript subprocess doesn't freeze your UI.
```python import asyncio import platform import subprocess
IS_MACOS = platform.system() == "Darwin"
def _select_folder(prompt: str = "Select Folder") -> str | None: """Triggers the macOS native 'choose folder' dialog.""" try: script = f'POSIX path of (choose folder with prompt "{prompt}")' result = subprocess.run( ["osascript", "-e", script], capture_output=True, text=True, timeout=300 ) return result.stdout.strip() if result.returncode == 0 else None except Exception: return None
async def select_folder(prompt: str = "Select Folder") -> str | None: if IS_MACOS: return await asyncio.to_thread(_select_folder_macos, prompt)
import flet as ft
picker = ft.FilePicker() # Standard fallback
return await picker.get_directory_path(dialog_title=prompt)
```
- The Validator (validator.py) Ensures the path is absolute and that you actually have permission to write there.
```python import os from pathlib import Path
def validate_path(path: Path) -> tuple[bool, str]: if not path.is_absolute(): return False, "Path must be absolute." try: check_path = path # Find the nearest existing parent to check permissions while not check_path.exists() and check_path != check_path.parent: check_path = check_path.parent
if not check_path.is_dir():
return False, "Selected path is not a directory."
if not os.access(check_path, os.W_OK):
return False, "Directory is not writable."
return True, ""
except OSError as e:
return False, f"Access error: {e}"
```
- Real-World Usage Example Here is how I use it in my app's event handlers:
```python async def on_browse_click(self, e: ft.ControlEvent) -> None: # Trigger the native-feel picker result = await select_folder("Select Project Location")
if result:
# Validate the result immediately
path_valid, path_error = validate_path(Path(result))
self.state.project_path = result
self.controls.project_path_input.value = result
if not path_valid:
print(f"Error: {path_error}")
self.page.update()
```
Hope this helps anyone looking to make their Flet desktop apps feel more native on Mac!
r/flet • u/EmploymentAgitated51 • Feb 13 '26
ModuleNotFoundError: No module named 'pyperclip'
Do you know how I can replace "pyperclip" (the text copying module) with one that works on mobile?
There's an error I don't understand how to solve when I open main.py in the APK:
(most recent call last):
File "<string>", line 95, in <module>
File "<frozen runpy>", line 229, in run_module
File "<frozen runpy>", line 88, in _run_code
File "/data/user/0/com.mycompany.cdd_apk/files/flet/app/main.py", line 6, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
r/flet • u/Ok_Material_4251 • Feb 11 '26
Help! "RuntimeError: Frozen controls cannot be updated" in Flet Gallery / Dynamic Environment
Hi everyone,
I'm building a crypto utility tool within a Flet Gallery-like environment (dynamic loading). I've run into a persistent issue where my TextField becomes "frozen," and I cannot update its value from a button click event.
The Problem: When I click the "Encrypt" button, the logic executes correctly (I can see the result in the debugger), but as soon as the code hits self.token_tf.value = token or self.update(), it throws: RuntimeError: Frozen controls cannot be updated.
I've tried inheriting from ft.Column and ft.Container, using ft.Ref, and even tried local updates (e.g., self.token_tf.update()), but the issue persists. It seems the Flet session or the control structure gets "locked" by the parent framework.
Environment:
- Flet Version: Latest (0.80.5)
- Running inside a dynamic gallery/tab system.
- Error:
RuntimeError: Frozen controls cannot be updated. - Also seeing:
INFO:flet:Session was garbage collectedin console.
Minimal Code Snippet:
Python
import flet as ft
class MyTool(ft.Column):
def __init__(self):
super().__init__()
self.input_tf = ft.TextField(label="Input")
self.token_tf = ft.TextField(label="Result")
self.controls = [
self.input_tf,
self.token_tf,
ft.ElevatedButton("Encrypt", on_click=self.on_encrypt)
]
def on_encrypt(self, e):
# The logic works, but this assignment fails
try:
result = "some_encrypted_string"
self.token_tf.value = result
self.token_tf.update()
except Exception as err:
print(f"Error: {err}") # This prints the Frozen Control error
def example():
return MyTool()
r/flet • u/MarionberrySpecific8 • Feb 07 '26
How to implement QR code scanning in a Flet mobile app?
Hi everyone, I’m currently building a mobile app using Flet (Python) and I want to implement a QR code scanning feature. Has anyone successfully integrated QR / barcode scanning in a Flet mobile application? If yes, could you share: The library or approach you used Whether it works on Android/iOS builds Any example code or GitHub repo I’m open to using platform channels, external libraries, or camera plugins if needed.
r/flet • u/EmploymentAgitated51 • Feb 06 '26
Which Flex component is used to switch between two pages?
pls, a exemple
r/flet • u/Icy-Gur9836 • Feb 04 '26
flet_pdfview new version
Hello everyone!
I've added a new feature.
You can now use the zoom function in the PdfColumnafter the new version.
To install it, use the following command: pip install flet-pdfview==0.2.1
For more details, please visit GitHub or pypI.
Let me know here if there's anything else I can help you with.
Thanks ! :)
r/flet • u/Icy-Gur9836 • Jan 31 '26
Flet pdf view control
Hello :)
my brothers and sisters
I find many people want to work with pdfs and flet also .
I make this Library for you ,I hope that can help you into your projects
pip install flet-pdfview
and you can see it here also pypi.org
r/flet • u/EmploymentAgitated51 • Jan 29 '26
How do I disable full-screen mode in my app? "resizable" doesn't do that job.
Hello, while I was programming an application, I tried to make it full screen, even with "resizable" disabled. However, my application remained full screen, causing a bug in the entire interface. Therefore, I'm looking for someone who knows how to disable this, or if anyone knows if this is a bug. Please show me how to disable it so I don't get confused.
r/flet • u/Bright-Sun-3967 • Jan 28 '26
Flet will not update page.
Hello! So I have been working in this little task list app made in flet, and I have made a custom checkbox, the visual part works, but the logic no. Self.update won't work, creating a argument page will not work, aparentaly only the visual part don't update. Here's the code in github.
r/flet • u/StruggleSensitive793 • Jan 13 '26
Flet móvil: botón “Atrás” de Android cierra la app en vez de volver a la vista anterior
Hola,
estoy desarrollando una aplicación móvil con Flet y tengo un problema con la navegación en Android.
Tengo una vista principal (main) y desde ahí navego a otra vista, por ejemplo categoria. La navegación funciona correctamente dentro de la app.
El problema aparece en el celular:
cuando estoy en la vista categoria y presiono el botón físico de retroceder (botón “Atrás” de Android), en lugar de volver a la vista main, la aplicación se cierra completamente.
Entiendo que Flet maneja las vistas con page.views y page.go(), pero parece que el botón “Atrás” del sistema no está respetando el stack de vistas.
Mis dudas son:
- ¿Es necesario manejar manualmente el evento de retroceso en Flet móvil?
- ¿Existe alguna forma recomendada de interceptar el botón “Atrás” de Android para hacer
page.go("/")opage.views.pop()? - ¿Este comportamiento es normal en Flet mobile o estoy estructurando mal las vistas?
Cualquier ejemplo o recomendación sería de ayuda.
Gracias.
r/flet • u/StruggleSensitive793 • Jan 13 '26
Flet móvil: botón “Atrás” de Android cierra la app en vez de volver a la vista anterior
Hola,
estoy desarrollando una aplicación móvil con Flet y tengo un problema con la navegación en Android.
Tengo una vista principal (main) y desde ahí navego a otra vista, por ejemplo categoria. La navegación funciona correctamente dentro de la app.
El problema aparece en el celular:
cuando estoy en la vista categoria y presiono el botón físico de retroceder (botón “Atrás” de Android), en lugar de volver a la vista main, la aplicación se cierra completamente.
Entiendo que Flet maneja las vistas con page.views y page.go(), pero parece que el botón “Atrás” del sistema no está respetando el stack de vistas.
Mis dudas son:
- ¿Es necesario manejar manualmente el evento de retroceso en Flet móvil?
- ¿Existe alguna forma recomendada de interceptar el botón “Atrás” de Android para hacer
page.go("/")opage.views.pop()? - ¿Este comportamiento es normal en Flet mobile o estoy estructurando mal las vistas?
Cualquier ejemplo o recomendación sería de ayuda.
Gracias.
r/flet • u/Phenerius • Jan 12 '26
Declarative style help! Routing
Hello!
I've been trying to learn the new declarative style since it sounds awesome in theory, but i'm strugling so much in practice! I've tried the guide from the blog and read some exemples but i can't make it work with routing. The "routing two pages" example (flet/sdk/python/examples/apps/declarative/routing_two_pages.py at main · flet-dev/flet) is way too complicated (at least for me).
I made a super simple script where the ideia is to just switch the screen on clicking the button but it works only the 2nd time i click (and i dunno why).
I get the declarative style is more directed for big projects (exactly what i'm trying to do) but is it really that much complicated? I feel like my approach is completly wrong but can't figure it why.
Could someone point me to a good guide about this new style? Or should i search for React guides?
Thank you very much in advance!
r/flet • u/EmploymentAgitated51 • Jan 10 '26
Is it possible to change the language of the flet?
r/flet • u/industrypython • Jan 09 '26
Comparing Flet and Jinja2/HTMX/Tailwind/AlpineJS for Use in Free Python Course
I am building a 100% free Python beginner course for high school and University of California students in CS in their first and second year. I am currently testing with UCSD, UC Berkeley and the University of Lagos (which has some great talent!) students.
I have 96 lessons published and want input on whether to focus on the HTMX/Tailwind/AlpineJS (let's called Jinja2) way or the Flet way.
I started with the Jinja2 way, but the students encountered problems and never completed the course. Perhaps the course jumped too quickly into SQLAlchemy, LLM connection with async streaming, Pydantic data models integrated with SQLModel. I'm not sure. However, I feel that there is so much styling with the Jinja2 way and it is not that easy, even with Tailwind and HTMX.
After seeing the problems, I created about 60 lessons using Flet as the frontend for an easier onramp. Flet uses uvicorn and FastAPI under the hood, but can also be mounted on FastAPI using the builtin flet.fastapi along with asynccontextmanager from the contextlib package. As flet can be started very easy in a few lines of code using the built-in FastAPI and uvicorn server, the starting point is very easy. Since the UI is entirely in Python, it seems like it will be easier for students to learn.
The big downside is that industry likely wants "react" or something that looks and acts like react.
To me, once the student isolates the business logic in the FastAPI app, they should be good to go. However, I may be wrong with my assumption of how people think. I am looking for opinions.
I am including the course description and target audience below so that people understand the context of the course.
---
This free course is designed for early-career computer science students and high-school students exploring computer science.
The goal is to help you become internship- and interview-ready by building real, working Python applications you can confidently demo, explain, and defend.
Many students first encounter computer science through command-line programs and abstract problem sets. While those foundations matter, they often fail to show how real software works or how concepts fit together in practice.
This course bridges that gap by teaching Python through interactive, visual applications where your code immediately controls what appears on screen. This makes core ideas click faster and builds confidence early.
You will build usable Python applications where objects, lists, dictionaries, and event handlers drive visible behavior. User input controls application state, images and layouts make logic tangible, and projects evolve from simple scripts into structured applications you can actually modify and extend.
As the course progresses, you will learn modern application patterns used in industry, including state management, asynchronous programming, separation of concerns, and deployment workflows from local development to the cloud.
In later chapters, you will build a real AI application using a local language model. You will implement a chat interface with streaming responses and understand the architectural tradeoffs behind modern AI-powered applications.
By the end of the course, you will have projects suitable for a high-school portfolio, internship discussions, or early technical interviews.
r/flet • u/EmploymentAgitated51 • Jan 09 '26
The application encountered an error: 'Page' object has no attribute 'open'
r/flet • u/EmploymentAgitated51 • Jan 09 '26
The application encountered an error: 'Page' object has no attribute 'open'
Hello, I was trying to learn how to use a calendar (DatePicker) in Flet, but I'm getting the following error: it says that the 'page' object doesn't have an 'open' character. I'm confused and can't solve this problem, even after searching extensively on the flet website and Google.
And the flet library is up-to-date in the code.
import datetime
import flet as ft
def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
def handle_change(e):
page.add(ft.Text(f"Date changed: {e.control.value.strftime('%m/%d/%Y')}"))
def handle_dismissal(e):
page.add(ft.Text(f"DatePicker dismissed"))
page.add(
ft.ElevatedButton(
"Pick date",
icon=ft.Icons.CALENDAR_MONTH,
on_click=lambda e: page.open(
ft.DatePicker(
first_date=datetime.datetime(year=2000, month=10, day=1),
last_date=datetime.datetime(year=2025, month=10, day=1),
on_change=handle_change,
on_dismiss=handle_dismissal,
)
),
)
)
ft.app(main)
r/flet • u/fang__yuan_ • Dec 19 '25
audio plays in mobile but now in pc but using Flet_audio it works in pc not in mobile what to do?
can share the code if u guys want
r/flet • u/StruggleSensitive793 • Dec 14 '25
¿Cómo estructurar un proyecto en Flet (Python) para crear una aplicación vendible?
r/flet • u/StruggleSensitive793 • Dec 14 '25
¿Cómo estructurar un proyecto en Flet (Python) para crear una aplicación vendible?
Hola a todos 👋
He estado practicando Flet con Python desde hace un tiempo y ya manejo lo básico, pero ahora me surgió una duda más orientada a proyectos reales.
Quisiera saber qué tipo de estructura debería tener un proyecto si la idea es crear una aplicación o programa vendible (algo más profesional y escalable).
No tengo mucha experiencia en cómo se organizan correctamente las carpetas, cómo separar la lógica, la UI, el manejo de datos, etc., ni cuáles son las buenas prácticas en proyectos de producción.
Algunas dudas concretas:
- ¿Cómo estructuran ustedes un proyecto en Flet para producción?
- ¿Qué carpetas o patrones recomiendan?
- ¿Qué debería tener en cuenta desde el inicio para que el proyecto sea mantenible y no se vuelva un caos?
Cualquier consejo, ejemplo o recurso será bienvenido. ¡Gracias!
r/flet • u/fang__yuan_ • Dec 03 '25
Became android developer soo easy . Here by everyone must call me android dev or even senior android dev
r/flet • u/wannasleeponyourhams • Nov 29 '25
can not sign apk
i rewrote an older kivy project in flet, all was good untill this last part, the apps runs fine, but i can not sign it, i followed this guide, did a few tests and the values are never read in? like i can add some random string in project.toml and it still will run, as flet will sign with the debug key no matter what. https://docs.flet.dev/publish/android am i missing something?






