Are you an expert in desktop apps and GUI development who want to also work with Python because of its simplicity, flexible use, and growing demand in the market out there? Or are you a Python Developer at any level who wants to start a GUI development journey? This article is for you.
We will review the two examples of the most powerful Python Desktop App and GUI Frameworks: Python For Delphi (P4D) VCL vs PySide GUI.
1. Python For Delphi VCL
How about combining the strength of GUI and desktop app development by Delphi with Python for your applications, to provide first-class solutions for your customer needs? Python4Delphi is the answer to your need!
Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi and Lazarus (FPC). They let you easily execute Python scripts, and powerfully create new Python modules and new Python types.
The best advantage of P4D is, it makes it very easy to use Python as a scripting language for Delphi applications that comes with a very extensive range of customizable demos and tutorials that ready to use to develop real-world apps. In shorts: P4D gives you various real-world “Hello World!” apps that ready to adjust to your needs!
Prerequisites: Before you begin to work with Python4Delphi VCL, download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out the easy instructions found in this video Getting started with Python4Delphi and the behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.
Here are some working example of it, runs on RAD Studio:
Demo31: Using WrapDelphi to access Delphi Form attributes:
Access Open Notify (Open APIs From Space) using Python REST Client from Delphi VCL:
2. PySide GUI
PySide is Python library to create cross-platform graphical user interfaces. It is a Python binding to the Qt framework. Qt library is one of the most powerful GUI libraries. It is developed by Digia and Qt Project.
PySide is implemented as a set of Python modules. Currently it has 15 modules. These modules provide powerful tools to work with GUI, multimedia, XML documents, network or databases.
How can we use PySide GUI?
The steps for using the GUI package PySide are:
- Install PySide using pip or easy install:
pip install PySide2
See the installation progress in your command prompt:
2. As with any other programming framework, you start with the traditional “Hello World” program.
Here is a simple example of an Hello World in PySide:
from PySide2.QtWidgets import QApplication, QLabel
app = QApplication(sys.argv)
#label = QLabel("Hello World!")
label = QLabel("<font color=red size=40>Hello World!</font>")
Let’s see how PySide “Hello World!” looks like in PyScripter IDE:
3. Creating Simple Form.
Let’s try another example: Creating a simple Form with a Button:
from PyQt5 import QtCore, QtGui, QtWidgets
def setupUi(self, Form):
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(70, 50, 75, 23))
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
See how it looks like by running it in PyScripter IDE:
Congratulations, you already learn the amazing example of GUI development by Python4Delphi vs PySide GUI!
Now it’s time for you to try it yourself, and please comment below for which one is your favorite that best suits your needs!