A graphical user interface, more commonly known as a GUI, is an important component of software application programming for human-computer interaction, replacing text-based commands with user-interactive visual actions. With the aid of a GUI, users can perform operations on a device, platform, program, or application without having to type commands or comprehend the underlying coding. So, if you want to learn how to create stunning GUI applications using Python, you’ve come to the right place! In this article, we will look at how to set up a multiplatform Delphi-Python GUI project to build GUI applications using some of the best Python GUI tools on the market.
Table of Contents
What are the essential requirements to create the Delphi Python GUI project setup?
If you want to create a Desktop GUI application for the multiplatform, the DelphiFMX Python package is the way, whereas the DelphiVCL Python package is the way to target the Windows platform only.
- DelphiFMX – Python package to develop Multi-platform (Windows, GNU/Linux, macOS, Android) GUI applications.
- DelphiVCL – Python package to develop Windows-only GUI applications.
What are DelphiFMX and DelphiVCL?
DelphiFMX and DelphiVCL are natively compiled Python packages that are powered by the Python4Delphi library. They’re free to use and distribute. They give Python developers access to Delphi’s rich and mature VCL and FireMonkey (FMX) GUI frameworks, which provides a simple way to create GUIs compatible across all platforms.
VCL by Embarcadero Delphi is a GUI framework for the Windows platform, whereas FireMonkey (FMX) is for native cross-platform application development that uses hardware-accelerated rendering via DirectX or OpenGL. Both of them have a strong styling system and are user-extensible.
How to Install DelphiFMX and DelphiVCL in Python?
The easiest way to install DelpiVCL and DelphiFMX Python packages is via PIP:
This is how to install DelphiFMX in Python
pip install delphifmx
This is how to install DelphiVCL in Python
pip install delphivcl
What are the additional requirements to create the perfect Delphi Python GUI project setup?
Products and tools like Delphi IDE, Delphi4PythonExporter, PythonFMXBuilder, and PyScripter allow Python developers to create all kinds of amazing professional quality applications easily.
To reduce the development time and for you to scale your GUI applications, we have built various tools:
- Delphi IDE – Download the Delphi IDE to design the UI of GUI applications and take advantage of the WYSIWYG preview of the UI.
- Delphi4PythonExporter – An open-source tool to export the UI designed in Delphi IDE to Python.
- PythonFMXBuilder – An open-source application to build, debug and deploy DelphiFMX-based GUI applications for the Android platform. This is not needed if you want to target only desktop applications.
- PyScripter – An open-source Python IDE to easily write code and run Python applications.
What is Delphi?
Delphi is an extremely powerful yet easy-to-learn object-oriented programming language. It has a Rapid Application Development (RAD) paradigm that can be used to create anything from database solutions to mobile applications. Delphi is noted for its ease of deployment of its apps, which do not require additional runtimes or dependencies, along with its robustness and single-source cross-platform capabilities. As a result, Delphi is widely regarded as the most efficient way to create, compile, package, and deploy cross-platform native applications for Windows, macOS, iOS, Android, and Linux.
How to install Delphi?
As a beginner, you have a few options to install the Delphi IDE. They are:
- Delphi Community Edition (CE)
- Delphi Trial
- Buy the Delphi license after the trial
Delphi Community Edition is an excellent tool for creating visually appealing, high-performance native Delphi apps for Windows, macOS, iOS, and Android. To install this IDE, visit: embarcadero.com/products/delphi/starter. Then, complete the form, and the download will begin:
The Delphi Community edition is free, so the required product key will be emailed to you. So all you have to do is extract and install the IDE.
When you start to feel confident about working with Delphi using Community Edition, you can consider the Delphi Architect Edition Trail for 30 days to discover the full power of Delphi. To install the Delphi Trail, visit: embarcadero.com/products/delphi/start-for-free.
What is Delphi4PythonExporter?
Delphi4PythonExporter, shortly known as D4PExporter, is a crucial offering for a thriving Python and Delphi ecosystem.
Python developers can use Delphi’s flagship UI design capabilities to save time writing design code in Python. They can use a WYSIWYG preview, including styles, as you design. In addition, users can also use the features at design time to connect event methods to various events on the GUI application (for example,
OnClick). Finally, Pythoneers can use the following approach to scale your large-scale Python GUI application.
Delphi developers can also benefit from the Exporter. They can use their Delphi skills to create great applications and then offer Python implementation of those applications, giving your new capabilities and providing an entirely new dimension. This allows users to create open-source GUIs in Python without writing a single line of design code in Python.
How to Install Delphi4PythonExporter?
You can export the UI of either FMX (Multi-platform) or VCL (Windows only) applications. However, most importantly, you can take advantage of assigning empty event methods at design time using D4PExporter. This reduces the tedious work of coding the events and their associated methods in Python. As you export the UI designed in Delphi IDE, you will see this in action. Once you have Delphi installed, open the Delphi IDE, select
Tools > GetIt Package Manager, and then search for
Delphi4PythonExporter in the search bar of the pop-up window.
Click on the correct search result and hit Install. Restart Delphi IDE for changes to take effect. Now, whenever you select Tools in the Delphi IDE, you will also see an Export To Python option.
What is PythonFMXBuilder?
The PythonFMXBuilder is an application builder for Python that uses DelphiFMX for Python to build Android applications. This allows you to bundle a custom Python script into an Android app, deploy it to your phone, and then submit it to the app store as per the requirement.
How to Install PythonFMXBuilder?
While PythonFMXBuilder is made with Delphi, it does not require Delphi to use it.
To install/run the PythonFMXBuilder application, download the latest release (pre-built binaries are provided in releases) from PythonFMXBuilder’s GitHub repository. Download the latest release at: github.com/Embarcadero/PythonFMXBuilder/releases/tag/v0.7.0
Select your version and download. Here we will use the latest Windows 64-bit binary:
.zip file and rename the folder to PythonFMXBuilder for simplicity.
PythonFMXBuilderGUI.exe executable application in the extracted folder by double-clicking it.
Next, download, install, and set up the Android SDK using the wiki guide link provided in the repository. Do the same for Java JDK using its wiki guide:
All these steps are provided in detail at: github.com/Embarcadero/PythonFMXBuilder/wiki/Step-by-step-guide-to-create-an-Android-application-using-PythonFMXBuilder
Now you’re all set with PythonFMXBuilder.
What is PyScripter?
PyScripter is a Python-integrated development environment (IDE) for Windows that is free and open source. It was created using Delphi’s Object Pascal and Python.
PyScripter started as a simple IDE to provide a powerful scripting solution for Delphi applications. It gradually evolved into a full-featured stand-alone Python IDE. It is written in Delphi and can be extended with Python scripts using Python4Delphi (P4D). It is relatively light compared to other IDEs because it is written in a compiled language. In addition, it is a portable IDE that can be used as a syntax highlighting editor, a Python interpreter and debugger, a file explorer, and a project manager, among other things. You can download the PyScripter from the following link: embarcadero.com/free-tools/pyscripter/free-download and install it.
Are you ready to build GUI applications using the Delphi Python Ecosystem?
This article covers both the essential and the ultimate workbench setup for building applications using The Delphi Python Ecosystem. Either you choose to go ahead with the minimal or the perfect setup that is mentioned above; we got you covered with an eBook to get you started. The eBook bundle contains the Getting Started with Python GUI development eBook, 15 DelphiFMX for Python Styles, and 13 DelphiVCL for Python styles. All styles support High DPI to help your applications look fantastic, and the DelphiFMX styles work seamlessly on all Windows, macOS, Linux, and Android platforms. The eBook covers the basics of programming Python with these libraries; no Delphi experience is necessary. So unlock your potential for excellent Python GUI development by downloading the eBook bundle at: lp.embarcadero.com/PythonGUIgettingStarted