In essence, DelphiVCL is a wrapper that helps to create and access Delphi Objects quickly from Python. These wrappers contain container classes to extend and expose your custom events, methods, variables that can be used in Python script.Here is a Python code sample using DelphiVCL to create a simple Form app with a list, edit, and button:
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 26 27 28 29 |
from delphivcl import * class MainForm(Form): def __init__(self, Owner): self.Caption = "A VCL Form..." self.SetBounds(10, 10, 340, 410) self.lblHello = Label(self) self.lblHello.SetProps(Parent=self, Caption="Hello Python") self.lblHello.SetBounds(10,10,100,24) self.edit1 = Edit(self) self.edit1.SetProps(Parent=self, Top=30, Left=10, Width=200, Height=24) self.button1 = Button(self) self.button1.SetProps(Parent=self, Caption="Add", OnClick=self.Button1Click) self.button1.SetBounds(220,29,90,24) self.lb1 = ListBox(self) self.lb1.SetProps(Parent=self) self.lb1.SetBounds(10,60,300,300) def Button1Click(self, Sender): self.lb1.Items.Add(self.edit1.Text) def main(): Application.Initialize() Application.Title = "My DelphiVCL4Python App" f = MainForm(Application) f.Show() FreeConsole() Application.Run() main() |
Here is the GUI created by the Python code above. You can run it using your favorite Python IDE, which for me is PyScripter:
Or you can save the script first, and run it through the command line using this command:
1 |
python.exe delphiVCLSample.py |
This GUI expects user inputs. Clicking the button will add the text from the edit box to the list box:
Table of Contents
Note for beta release users
In practice, the only difference between DelphiVCL for Python release version and the beta version is only in how you write the DelphiVCL. Here is the example for how you import the library:
- Release version:
1 |
from delphivcl import * |
- Beta version:
1 |
from DelphiVCL import * |
Watch this comprehensive introduction to Python GUI Development with DelphiVCL library video by Jim McKeeth:
Also, watch the following webinar by Alexey Sharagin to Master the Secrets of Beautiful Modern Windows Apps:
Check out DelphiVCL which easily allows you to build GUIs for Windows using Python.
Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi.
References & further readings
[1] Anbarasan. (2021).
Quickly Build Ultra-Modern Python Native Windows GUIs With Delphi. PythonGUI.org. Embarcadero Technologies. pythongui.org/quickly-build-ultra-modern-python-native-windows-guis-with-delphi