Are you an expert in desktop apps and GUI development who also want to 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? If you check both of those boxes, then 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 wxPython.
Table of Contents
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:
Let’s try this interesting Demo, Demo33: Using Threads inside Python:
And this amazing Demo, Demo29: Using Python Imaging Library (PIL) to read image and perform Image Processing:
2. wxPython
wxPython is a cross-platform toolkit for creating desktop GUI applications. With wxPython developers can create applications on Windows, Mac, and on various Unix systems. wxPython is a wrapper around wxWidgets, which is a mature cross-platform C++ library. The initial release of wxPython was in 1998, so wxPython has been around quite a long time.
wxPython developed and maintained by Robin Dunn, awardee of the ActiveState Programmers’ Choice Award at the 2002 O’Reilly Open Source Convention.
How can we use wxPython?
The steps for using the GUI package wxPython are:
- Install wxPython using pip or easy install:
1 |
pip install wxpython |
See the installation progress in your command prompt:
2. Creating a Skeleton Application
An application skeleton in a GUI context is a user interface with widgets that don’t have any event handlers. These are useful for prototyping. You basically just create the GUI and present it to your stakeholders for sign-off before spending a lot of time on the backend logic.
Let’s start by creating a Hello World application with wxPython, and run it in our PyScripter IDE:
1 2 3 4 5 6 |
import wx app = wx.App() frame = wx.Frame(parent=None, title='Hello World') frame.Show() app.MainLoop() |
3. Read the demo files
Similar with Python4Delphi VCL, wxPython comes with a comprehensive set of demos and examples. Go to the download page and scroll down to the wxPython-demo-x.x.x files. The demo demonstrates nearly all the features of wxPython. You can see how different features work and study the source code.
Conclusion
Congratulations, you have already learned the amazing example of GUI development by Python4Delphi vs wxPython!
Go ahead and try it for yourself! Comment your favorite one below that best suits your needs.
Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi.