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 setup 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 requirements to create the Delphi Python GUI project setup?
Products and tools like Delphi Community Edition, DelphiFMX, DelphiVCL, PyScripter, Delphi4PythonExporter, and PythonFMXBuilder allow Python developers to create all kinds of amazing professional quality applications very easily.
If you want to create a Desktop GUI application for the Windows Platform only, DelphiVCL Python package is the way, whereas DelphiFMX Python package is the way to go for multiplatform.
But to reduce the development time and for you to scale your GUI applications, we have built various tools:
- Delphi Community Editon – Download the Delphi IDE to design the UI of GUI applications and take advantage of the WYSIWYG preview of the UI.
- Delphi4PythonExporter – Tool to export the UI designed in Delphi IDE to Python.
- DelphiVCL – Python package to develop Windows-only GUI applications.
- DelphiFMX – Python package to develop Multi-platform (WIndows, GNU/Linux, macOS, Android) GUI applications.
- PythonFMXBuilder – 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 – A Python IDE to write code and run Python applications with ease.
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 the ease of deployment of its apps – which do not require any 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 Community Edition?
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:
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.
What is Delphi4PythonExporter?
Delphi4PythonExporter is a critical 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 provide an entirely new dimension. This allows users to create open-source GUIs in Python without writing a single line of design code in Python.
It is important to note that you need Delphi IDE to take advantage of the exporter. So you can install any of the following options:
- Delphi Community Edition (CE)
- Delphi Trial
Another important point is that you can export the UI of either VCL (Windows only) applications or FMX (Multi-platform) applications. However, most importantly, you can take advantage of assigning empty event methods at design time. This reduces the tedious work of coding the events and their associated methods in Python. You will see this in action as you export the UI designed in Delphi IDE. Once you have Delphi installed, open the Delphi IDE, select
Tools > GetIt Package Manager, and then simply 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 are DeplhiVCL and DeplhiFMX?
DelphiVCL and DelphiFMX are natively compiled Python modules powered by the Python4Delphi library. They’re free to use and distribute, and 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 Windows platform whereas FireMonkey (FMX) is for native cross-platform application development that uses hardware-accelerated rendering via DirectX or OpenGL. They also have a strong styling system and are user extensible.
How to Install DelphiVCL and DelphiFMX?
Easiest way to install DelpiVCL and DelphiFMX Python packages is via PIP:
pip install delphivcl
pip install delphifmx
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 PythonFMXBuilder, you first have to download the latest release (prebuilt 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.
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.
How to Install PyScripter?
Download the PyScripter from the following link: embarcadero.com/free-tools/pyscripter/free-download