RAD Studio Python For Delphi VCL vs Tkinter

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,203
Credits
4,034
Python For Delphi VCL vs Tkinter
February 14, 2021 By Muhammad Azizul Hakim

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.

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 Для просмотра ссылки Войди или Зарегистрируйся for your platform. Follow the Для просмотра ссылки Войди или Зарегистрируйся installation instructions mentioned Для просмотра ссылки Войди или Зарегистрируйся. Alternatively, you can check out the easy instructions found in this video Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся.

Here are some working example of it, runs on RAD Studio:
1613304884380.png
Demo01 to Run any Python Scripts on Delphi.

Running a Python Web Server with Python For Delphi VCL:
1613304907547.png
Connect to a database using Python For Delphi VCL:
1613304920089.png

2. Tkinter​

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:

  1. Importing the module – tkinter
  2. Create the main window (container)
  3. Add any number of widgets to the main window
  4. 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)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
 
mainloop()
See how it looks like in PyScripter IDE:
1613304963593.png
See our created GUI by PySimpleGUI:
1613304974875.png

Conclusion​

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!