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 Tkinter.
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:
Running a Python Web Server with Python For Delphi VCL:
Connect to a database using Python For Delphi VCL:
Python has lots of GUI frameworks, but Tkinter is the only built-in framework in the Python standard library. Tkinter has several strengths. It’s cross-platform, so the same code works on Windows, macOS, and Linux. Visual elements in Tkinter rendered using native operating system elements, so applications built with Tkinter look like they belong to the platform where they are running.
Although Tkinter is considered the de-facto Python GUI framework, it’s not without criticism. One notable critic is that GUIs built with Tkinter look outdated. If you want a shiny, modern interface, then Tkinter may not be what you’re looking for.
However, Tkinter is lightweight and relatively painless to use compared to other frameworks. This makes it a compelling choice for building GUI applications in Python, especially for applications where a modern sheen is unnecessary, and the top priority is to build something functional and cross-platform quickly.
How can we use Tkinter?
Below are the steps to create a Tkinter app:
- Importing the module – tkinter
- Create the main window (container)
- Add any number of widgets to the main window
- Apply the event Trigger on the widgets.
Let’s create a simple app that expects input from users. Run this example in the PyScripter IDE:
from tkinter import *
master = Tk()
Label(master, text='First Name').grid(row=0)
Label(master, text='Last Name').grid(row=1)
e1 = Entry(master)
e2 = Entry(master)
See how it looks like in PyScripter IDE:
See our created GUI by PySimpleGUI:
Congratulations, you already learn the amazing example of GUI development by Python4Delphi vs Tkinter!
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!
Watch this comprehensive introduction to Python GUI Development with DelphiVCL library video by Jim McKeeth: