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 PySimpleGUI.
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.
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:
Python REST Client:
Read image and perform Image Processing with Python Imaging Library (PIL):
2. PySimpleGUI
PySimpleGUI is easy to use with simple yet HIGHLY customizable features of GUI for Python. It is based solely on Tkinter. It is a Python GUI designed for humans that Transforms Tkinter, PyQt, Remi, WxPython into portable user-friendly Pythonic interfaces.
How can we use PySimpleGUI?
The Steps for using the GUI package PySimpleGUI are:
- Install PySimpleGUI using pip or easy install:
1 |
pip install PySimpleGUI |
See the installation progress in your command line:
2. Find a GUI that looks a lot similar to which you want to design and create.
3. Copy code from Cookbook or documentations.
4. Paste into your IDE and run. Here’s the example that I run in the PyScripter IDE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import PySimpleGUI as sg sg.theme('BluePurple') layout = [[sg.Text('Your typed characters appear here:'), sg.Text(size=(15,1), key='-OUTPUT-')], [sg.Input(key='-IN-')], [sg.Button('Display'), sg.Button('Exit')]] window = sg.Window('Introduction', layout) while True: event, values = window.read() print(event, values) if event in (None, 'Exit'): break if event == 'Display': # Update the "output" text element # to be the value of "input" element window['-OUTPUT-'].update(values['-IN-']) window.close() |
See how it looks like in PyScripter IDE:
See our created GUI by PySimpleGUI:
Conclusion
Congratulations, you already learn the amazing example of GUI development by Python4Delphi vs PySimpleGUI!