delphivcl.Application
is the type used for a GUI windowed application. Application
encapsulates a windowed application. The methods and properties introduced in the Application
reflect the fundamentals established in the Windows operating system to create, run, sustain, and destroy an application.
Application
thereby simplifies the interface between the developer and the Windows environment. For this purpose, the Application
encapsulates behavior for:
- Windows message processing
- Context-sensitive online help
- Menu accelerator and key processing
- Exception handling
- Managing the fundamental parts defined by the Windows operating system for an application, such as
MainWindow
,WindowClass
, and so on
Each GUI application automatically declares an Application
variable as the instance of the application. If the application is not a Web server application, control panel applet, or NT service application, this variable is of type Application
.
Application
does not appear on the Component
palette, nor is it available in the form designer to visually manipulate; so it has no published properties.
We can browse all the properties, methods, and built-in properties of the delphivcl.Application
in Python using dir()
command:
1 2 3 |
import delphivcl dir(delphivcl.Application) |
See the responses in command prompt:
See them more clearly here:
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
['ActionUpdateDelay', 'ActivateHint', 'Active', 'ActiveFormHandle', 'AddPopupForm', 'AfterConstruction', 'AllowTesting', 'ApplyBiDiKeyboardLayout', 'ApplyNonBiDiKeyboardLayout', 'Assign', 'AutoDragDocking', 'BeforeDestruction', 'BeginInvoke', 'BiDiKeyboard', 'BiDiMode', 'BindMethodsToEvents', 'BringToFront', 'CPP_ABI_1', 'CPP_ABI_2', 'CPP_ABI_3', 'CancelHint', 'ClassInfo', 'ClassName', 'ClassNameIs', 'ClassParent', 'ClassType', 'CleanupInstance', 'ComObject', 'ComponentCount', 'ComponentIndex', 'ComponentState', 'ComponentStyle', 'Components', 'ControlDestroyed', 'Create', 'CreateForm', 'CreateHandle', 'CurrentHelpFile', 'DefaultFont', 'DefaultHandler', 'DesignInfo', 'Destroy', 'DestroyComponents', 'Destroying', 'DialogHandle', 'Dispatch', 'DisposeOf', 'DoApplicationIdle', 'EndFunctionInvoke', 'EndInvoke', 'EnumAllWindowsOnActivateHint', 'Equals', 'ExeName', 'ExecuteAction', 'FieldAddress', 'FindComponent', 'Free', 'FreeInstance', 'FreeNotification', 'FreeOnRelease', 'GetEnumerator', 'GetHashCode', 'GetInterface', 'GetInterfaceEntry', 'GetInterfaceTable', 'GetNamePath', 'GetParentComponent', 'Handle', 'HandleException', 'HandleMessage', 'HasParent', 'HelpCommand', 'HelpContext', 'HelpFile', 'HelpJump', 'HelpKeyword', 'HelpShowTableOfContents', 'HelpSystem', 'HideHint', 'Hint', 'HintColor', 'HintHidePause', 'HintMouseMessage', 'HintPause', 'HintShortCuts', 'HintShortPause', 'HookMainWindow', 'HookSynchronizeWakeup', 'Icon', 'InRemoteSession', 'InheritsFrom', 'InitInstance', 'Initialize', 'InsertComponent', 'InstanceSize', 'IsImplementorOf', 'IsMetropolisUI', 'IsRightToLeft', 'MainForm', 'MainFormHandle', 'MainFormOnTaskBar', 'MessageBox', 'MethodAddress', 'MethodName', 'Minimize', 'ModalFinished', 'ModalLevel', 'ModalPopupMode', 'ModalStarted', 'Name', 'NewInstance', 'NonBiDiKeyboard', 'NormalizeAllTopMosts', 'NormalizeTopMosts', 'Observers', 'OnActionExecute', 'OnActionUpdate', 'OnActivate', 'OnDeactivate', 'OnException', 'OnGetActiveFormHandle', 'OnGetMainFormHandle', 'OnHelp', 'OnHint', 'OnIdle', 'OnMessage', 'OnMinimize', 'OnModalBegin', 'OnModalEnd', 'OnRemoteSessionChanged', 'OnRestore', 'OnSettingChange', 'OnShortCut', 'OnShowHint', 'Owner', 'PopupControlWnd', 'ProcessMessages', 'QualifiedClassName', 'ReferenceInterface', 'RemoveComponent', 'RemoveFreeNotification', 'RemovePopupForm', 'Restore', 'RestoreTopMosts', 'Run', 'SafeCallException', 'SetProps', 'SetSubComponent', 'ShowException', 'ShowHint', 'ShowMainForm', 'SingleBufferingInRemoteSessions', 'Tag', 'Terminate', 'Terminated', 'Title', 'ToList', 'ToString', 'ToTuple', 'UnhookMainWindow', 'UnhookSynchronizeWakeup', 'UnitName', 'UnitScope', 'UpdateAction', 'UpdateFormatSettings', 'UpdateMetricSettings', 'UseMetropolisUI', 'UseRightToLeftAlignment', 'UseRightToLeftReading', 'UseRightToLeftScrollBar', 'VCLComObject', '__bound__', '__dir__', '__owned__'] |
Let’s create a Python main function that can run and close an application window:
1 2 3 4 5 6 7 8 9 10 |
def main(): Application.Initialize() Application.Title = "MyDelphiApp" f = MainForm(Application) f.Show() FreeConsole() Application.Run() Application.Destroy() main() |
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] Embarcadero DocWiki. (2011).
Vcl.Forms.TApplication
. Embarcadero DocWiki. Embarcadero Technologies. docwiki.embarcadero.com/Libraries/Sydney/en/Vcl. Forms.TForm