Discover how Embarcadero’s new free Python modules bring the power and flexibility of Delphi’s GUI frameworks to Python GUI. VCL and FireMonkey (FMX) are mature graphical user interface libraries. VCL is primarily used for native Windows development, whereas FireMonkey provides a powerful and flexible GUI framework for Windows, Linux, macOS, and even Android.
In this webinar, we will introduce you to these new free Python modules and show you how to use them to create graphical user interfaces with Python. Part 2 will show you how to target Android GUI applications with Python! We recommend using a python android app builder software for cross-platform GUI framework creation so that your experience is smooth and you can maximize your python potential!
- Find Delphi FMX for Python on GitHub or install via pip with:
pip install delphifmx
- Slides [Download PDF from GitHub] [View on Google Sides] [View on SlideShare]
- Check out Part one on Delphi VCL for Python.
Table of Contents
Who are you?
● Python devs who want a nice GUI
● Python devs curious about Delphi
● Delphi devs who want to use Python
● Delphi devs curious about what’s new
● Other devs curious about Delphi & Python
It’s not a Competition
● Developers have multiple tools on their workbench
● It is about finding the right tool for each task
● Having specialized tools for different tasks doesn’t detract from favorite tools
● You can always find a specific task that another tool is better for, but no one tool is that best for all tasks.
What is Delphi for Python?
- Set of free Python modules bringing Delphi’s GUI libraries to Python developers
- Mature, feature rich, native & cross-platform
- Does not require Delphi to use
- Based on the open source Python4Delphi (same technology that powers the PyScripter IDE)
- Available today on GitHub & PyPi
- Currently in beta, but ready for use
- DelphiVCL for Python supports Windows (32-bit & 64-bit)
- DelphiFMX for Python adds Linux, Android, & Mac OS
- Part of a bidirectional bridge between Delphi and Python
Dissecting the Technology Stacks
FMX The Cross-Platform (FireMonkey Framework)
- Takes advantage of GPU libraries to provide a hardware accelerated, rich user interface that is fast and looks great across multiple platforms:
- Windows, macOS, iOS, Android, and Linux
- Uses DirectX on Windows, OpenGL on Linux, OpenGL-ES on Android, and Metal on iOS and macOS
- Similar to VCL, but not designed to be compatible
- Designed as cross platform from the ground up
- Integrated GPU effects, animations, and robust styling system
- Platform services abstract the access to platform hardware and functionality to intelligently adapt the UI & UX to platform specifics
- Very flexible component system – do more with fewer components
Delphi for Python
Delphi FMX for Python Installation
- Install via pip
pip install delphifmx
- Supports:
- Win32 x86, Win64 x86, Linux64 x86, Android64, Mac OS x64 (Intel) and Mac M1 (Arm) architectures
- Python cp3.6, cp3.7, cp3.8, cp3.9 and cp3.10 (excluding cp3.6 on Linux and macOS)
- Conda support:
- Win x86 and x64 from Python cp3.6 to cp3.10
- Linux x86_64 from Python cp3.7 to cp3.9 (Recommended!)
- macOS not supported yet
- Details and downloads
Hello World (The simplest example)
https://github.com/Embarcadero/DelphiFMX4Python/blob/main/samples/Simplest.py
Hello World (An Object Oriented example)
https://github.com/Embarcadero/DelphiFMX4Python/blob/main/samples/HelloDelphiFMX.py
ToDo App (Starting to get useful….)
https://github.com/Embarcadero/DelphiFMX4Python/blob/main/samples/ToDoList.py
With Style (And more controls)
https://github.com/Embarcadero/DelphiFMX4Python/tree/main/samples/ControlsDesktop
Design Your UI (in the Delphi IDE)
● Take full advantage of the Delphi IDE designers and property editors
● WYSIWYG preview with styles
● Export the form for use in Python then write Python code
● Just right-click and export with the IDE add-in
● Works with any Delphi edition requires no Object Pascal
● github.com/Embarcadero/DelphiFMX4Python/tree/main/experts
● Currently uses a binary .pydfm file, but text version coming
Exported from Delphi’s FMX Designers to Python (with Styles)
Exported from Delphi’s FMX Designers to Python (with Styles and Animations)
Deploying Python to Android… Yes, Python on Android! (The Architecture)
Fundamentals
- Delphi FMX supports Android ARM64 as a target
- The Python4Delphi library supports Android
- Allows building Delphi app to run Python on Android
Solution
- A pre-built Delphi application with Python enabled
- User modifiable Python script payload that runs automatically
- Automated tool to modify the Android Manifest and build final APK
- On GitHub github.com/Embarcadero/PythonFMXBuilder (alpha?)
- Or resign modified APK manually
To Do
- Live preview before deploying to Android
- Bundling multiple Python scripts & modules
- Customize icons, splash screens, loading, etc.
- More testing, debugging, and your suggestions….
Running Python on Android
● Delphi compiles natively for Android
● The Python runtime is embedded into the app
● Python is dynamically interpreted and executed at runtime
● All of Delphi FMX for Python is available
● Supports additional Python modules
● Completely local – no network access necessary
https://github.com/Embarcadero/PythonFMXBuilder
Combine Delphi and Python
- The Python4Delphi library is a bidirectional bridge
- Develop parts of your solution in Delphi, and part in Python
- Play to the strengths of each
- Merge them together into a single cohesive solution
- Find samples, tutorials, and videos
Use Delphi to Create Native Python Modules
● Many Python modules are written in C/C++ and natively compiled
● Delphi also creates natively compiled Python modules via Python4Delphi
● Prototype rapidly in Python, and then create optimized modules in Delphi to clear bottlenecks
● Much like Python, Delphi code is focused on readability and clear structure and may be easier for you than using C/C++
● Augment your use of PyPy or Cython
Documentation and Library References
- Main Delphi documentation
- Library Reference
- Delphi prefixes type names with a “T”
- TEdit in Delphi is an Edit in Python
- It is just a naming convention
About PyScripter
● Popular open-source Python IDE sponsored by Embarcadero
● All the features expected in a modern Python IDE while being lightweight and very fast
● Natively compiled for Windows to use minimal memory with maximum performance
● Full Python debugging with remote debugging
● Integration with Python tools like PyLint, TabNanny, Profile, etc.
● Run or debug files from memory.
● embarcadero.com/free-tools/pyscripter/free-download
About UltraEdit
- High performance text editor for programmers.
- Industry’s best large file handling: 10+ GB and beyond.
- Syntax highlighting for nearly any language or data format.
- Smart templates.
- Hex editing. Column / block mode editing.
- Part of Idera family of developer tools.
- ultraedit.com/products/ultraedit
Next Steps
- Install Delphi FMX for Python github.com/Embarcadero/DelphiFMX4Python
- See the samples, Star the Repository, file issues, and make feature requests
- Read the blog post (links, replays) blogs.embarcadero.com/?p=130176
- See part 1 on Delphi VCL blogs.embarcadero.com/?p=128183
- Start a 30-day Delphi trial embarcadero.com/products/delphi/start-for-free
- Subscribe on YouTube youtube.com/c/EmbarcaderoTechnologies
- Follow us on Twitter twitter.com/embarcaderotech
- Like us on Facebook facebook.com/embarcaderotech
- Follow us on LinkedIn linkedin.com/company/embarcadero-technologies
- Read our blog pythongui.org
Interested in building Linux applications with FireMonkey? Try the Cross-Platform Development Framework, which can help you create & design apps in Delphi or C++ environments.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
2 Comments