Learn Python with Talk Python's 270 hours of courses

Flet: Flutter apps in Python

Episode #378, published Sun, Aug 21, 2022, recorded Thu, Aug 18, 2022

Have you heard of Flutter? It's a modern and polished UI framework to write mobile apps, desktop apps, and even web apps. While interesting, you may have kept your distance because Flutter is a Dart language-based framework. But with the project we're covering today, Flet, many Flutter UIs can now be written in pure Python. Flet is a very exciting development in the GUI space for Python devs. And we have the creator, Feodor Fitsner, here to take us through it.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guests Background

Feodor (Fyodor) Fitsner is the creator of Flet and a long-time .NET developer who transitioned into Python to explore new ways to build user interfaces. Drawing on his experience working with Microsoft technologies, he built Flet as a Python-friendly framework powered by Flutter. Throughout the conversation, Fyodor shares insights into why he built Flet, how it fits into the Python ecosystem, and what developers of all backgrounds can expect from it.

What to Know If You're New to Python

  • Have a basic grasp of Python’s syntax and structure, including functions and imports.
  • Understand the idea of creating and adding third-party libraries (e.g. via pip install).
  • Know that Python can integrate with web technologies and client-side frameworks, which is crucial for understanding how Flet bridges Flutter and Python.

Key Points and Takeaways

  1. The Vision Behind Flet Flet arose from the desire to let Python developers build modern and visually appealing UIs without having to switch to Dart. Fyodor’s background in .NET led him to value simplicity and an imperative style, which Flet brings to Flutter’s otherwise declarative approach.

  2. Bridging Python and Flutter Instead of transpiling Python code into Dart, Flet relies on a server model that communicates with a precompiled Flutter front-end. All the UI rendering happens in Flutter while logic, events, and state management run in Python. This design preserves Python’s ecosystem (e.g. access to scientific libraries) while benefiting from Flutter’s slick UIs.

  3. Flet’s Imperative Programming Approach While Flutter uses a declarative style, Flet allows you to update widgets in an imperative way (e.g., button.text = "Clicked"). Some developers find this more natural, especially if they come from frameworks like WinForms or ASP.NET.

  4. Packaging and Distribution Flet bundles a Flutter engine, so you can distribute your Python-based UIs as desktop executables or run them as web apps. Tools like pyinstaller help package the entire solution into a single file, creating cross-platform applications that contain both the Python logic and the Flutter rendering engine.

  5. Handling Events in Python Events (like button clicks and text changes) are routed back to the Python code over WebSockets, letting you handle UI logic and business logic in one place. This structure keeps all your Python libraries available for event-driven tasks, from data analysis to database transactions.

  6. Where Flet Fits Among Other Python GUI Frameworks Flet is positioned as a straightforward way to produce polished UIs and includes a built-in web server for quick sharing or deployment. While tools like Kivy, PyQt, or Tkinter also do GUIs in Python, Flet leverages Flutter’s cross-platform engine for a uniform look across devices.

  7. Mobile Experience and Roadmap Native APK or iOS packaging is still a work in progress, but the team is actively exploring ways to embed Python and Go on mobile. In the meantime, Progressive Web Apps (PWAs) and web-driven server deployments can provide mobile-friendly solutions with less overhead.

  8. Using Python Libraries in a Flet App Because your business logic runs on CPython, any library, such as machine learning with PyTorch, or data manipulation with pandas, can be integrated directly. This is one of the major advantages of keeping Python as the execution engine.

  9. Community and Contribution Flet is open source, and Fyodor welcomes help with tutorials, documentation, and bug fixes. The project aims for an inclusive community to refine features and add new controls or layout components.

  10. Future Possibilities Beyond desktop apps and server-hosted web apps, the future of Flet includes deeper adaptive styling for each platform (Windows, macOS, iOS, Android). Flutter’s built-in Cupertino, Material, and other design libraries mean Flet can evolve into a platform where Python seamlessly matches native styles.

Interesting Quotes and Stories

  • On packaging Python and Flutter together: “I spent a lot of nights trying to package these wheels right… to include these binaries. It’s pretty cool.”
  • On bridging two ecosystems: “The problem is not Dart itself—Dart is a great language. But some people want to stay in Python for everything and still get that polished UI.”

Key Definitions and Terms

  • Flutter: A UI toolkit from Google for building cross-platform apps (web, mobile, desktop) with near-native performance.
  • Dart: The language typically used for Flutter, known for its speed and strong type system.
  • Imperative UI Programming: A style where you explicitly update component properties to reflect the current state.
  • Declarative UI Programming: A style where the UI is redrawn based on a function of the current state, often used by React and Flutter.

Learning Resources

Here are a few resources if you want to delve deeper into Python fundamentals and UI development:

Overall Takeaway

Flet demonstrates the power of combining Python’s rich ecosystem with Flutter’s visually appealing, cross-platform framework. Developers can leverage their existing Python knowledge—along with familiar libraries for everything from analytics to data storage—and pair it with modern UI components that Flutter provides. Whether you’re a hobbyist looking to share a simple dashboard or a developer testing prototypes before possibly migrating to pure Flutter, Flet offers an accessible and exciting path to building polished apps in Python.

Links from the show

Feodor on GitHub: github.com
Flet: flet.dev
Flutter: flutter.dev
Dart: dart.dev
Flet Tutorials: flet.dev
It's All Widgets Showcase: itsallwidgets.com
Roadmap: flet.dev
pglet: pglet.io
Flutter Flow Designer: flutterflow.io
Fluent UI for Flutter Showcase App: bdlukaa.github.io
macOS UI: pub.dev
Flet Mobile Strategy: flet.dev
Michael's flutter doctor output: flutter-doctor.png
Pyscript: pyscript.net
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon