Skip to content

Commit abddced

Browse files
authoredOct 20, 2020
Merge pull request #203 from jimmckeeth/master
Renamed the Delphi module to DelphiVCL
2 parents 27e7b2e + 1436ff7 commit abddced

File tree

9 files changed

+944
-218
lines changed

9 files changed

+944
-218
lines changed
 

‎Modules/Delphi/Delphi.dpr

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎Modules/Delphi/Delphi.dproj

Lines changed: 0 additions & 108 deletions
This file was deleted.

‎Modules/Delphi/TestApp.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎Modules/DelphiVCL/DelphiVCL.dpr

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library DelphiVCL;
2+
3+
uses
4+
SysUtils,
5+
Classes,
6+
uMain in 'uMain.pas';
7+
8+
{$I Definition.Inc}
9+
10+
exports
11+
// This must match the pattern "PyInit_[ProjectName]"
12+
// So if the project is named DelphiVCL then
13+
// the export must be PyInit_DelphiVCL
14+
PyInit_DelphiVCL;
15+
{$IFDEF MSWINDOWS}
16+
{$E pyd}
17+
{$ENDIF}
18+
{$IFDEF LINUX}
19+
{$SONAME 'DelphiVCL'}
20+
21+
{$ENDIF}
22+
23+
begin
24+
end.
25+

‎Modules/DelphiVCL/DelphiVCL.dproj

Lines changed: 814 additions & 0 deletions
Large diffs are not rendered by default.

‎Modules/DelphiVCL/TestVCL.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from DelphiVCL import *
2+
3+
class MainForm(Form):
4+
5+
def __init__(self, Owner):
6+
self.Caption = "A VCL Form..."
7+
self.SetBounds(10, 10, 500, 400)
8+
9+
self.lblHello = Label(self)
10+
self.lblHello.SetProps(Parent=self, Caption="Hello Python")
11+
self.lblHello.SetBounds(10, 10, 300, 24)
12+
13+
self.edit1 = Edit(self)
14+
self.edit1.SetProps(Parent=self)
15+
self.edit1.SetBounds(10, 30, 250, 24)
16+
17+
self.button1 = Button(self)
18+
self.button1.Parent = self
19+
self.button1.SetBounds(270,24,100,30)
20+
self.button1.Caption = "Add"
21+
self.button1.OnClick = self.Button1Click
22+
23+
self.lb1 = ListBox(self)
24+
self.lb1.Parent = self
25+
self.lb1.SetBounds(10,60,300,300)
26+
27+
self.OnClose = self.MainFormClose
28+
29+
def MainFormClose(self, Sender, Action):
30+
Action.Value = caFree
31+
32+
def Button1Click(self, Sender):
33+
self.lb1.Items.Add(self.edit1.Text)
34+
self.edit1.Text = ""
35+
36+
def main():
37+
Application.Initialize()
38+
Application.Title = "MyDelphiApp"
39+
f = MainForm(Application)
40+
f.Show()
41+
FreeConsole()
42+
Application.Run()
43+
44+
main()
45+
Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
1-
unit uMain;
2-
3-
interface
4-
5-
uses PythonEngine;
6-
7-
function PyInit_Delphi: PPyObject; cdecl;
8-
9-
implementation
10-
11-
uses WrapDelphi, WrapDelphiVCL;
12-
13-
var
14-
gEngine : TPythonEngine;
15-
gModule : TPythonModule;
16-
gDelphiWrapper : TPyDelphiWrapper;
17-
18-
function PyInit_Delphi: PPyObject;
19-
begin
20-
try
21-
gEngine := TPythonEngine.Create(nil);
22-
gEngine.AutoFinalize := False;
23-
gEngine.UseLastKnownVersion := False;
24-
// Adapt to the desired python version
25-
gEngine.RegVersion := '3.8';
26-
gEngine.DllName := 'python38.dll';
27-
28-
gModule := TPythonModule.Create(nil);
29-
gModule.Engine := gEngine;
30-
gModule.ModuleName := 'Delphi';
31-
32-
gDelphiWrapper := TPyDelphiWrapper.Create(nil);
33-
gDelphiWrapper.Engine := gEngine;
34-
gDelphiWrapper.Module := gModule;
35-
36-
gEngine.LoadDll;
37-
except
38-
end;
39-
Result := gModule.Module;
40-
end;
41-
42-
initialization
43-
finalization
44-
gEngine.Free;
45-
gModule.Free;
46-
gDelphiWrapper.Free;
47-
end.
48-
49-
1+
unit uMain;
2+
3+
interface
4+
5+
uses PythonEngine;
6+
7+
function PyInit_DelphiVCL: PPyObject; cdecl;
8+
9+
implementation
10+
11+
uses WrapDelphi, WrapDelphiVCL;
12+
13+
var
14+
gEngine : TPythonEngine;
15+
gModule : TPythonModule;
16+
gDelphiWrapper : TPyDelphiWrapper;
17+
18+
// This must match the pattern "PyInit_[ProjectName]"
19+
// So if the project is named DelphiVCL then
20+
// the function must be PyInit_DelphiVCL
21+
function PyInit_DelphiVCL: PPyObject;
22+
begin
23+
try
24+
gEngine := TPythonEngine.Create(nil);
25+
gEngine.AutoFinalize := False;
26+
gEngine.UseLastKnownVersion := False;
27+
// Adapt to the desired python version - Will only work with this version
28+
gEngine.RegVersion := '3.9';
29+
gEngine.DllName := 'python39.dll';
30+
31+
gModule := TPythonModule.Create(nil);
32+
gModule.Engine := gEngine;
33+
// This must match the ProjectName and the function name pattern
34+
gModule.ModuleName := 'DelphiVCL';
35+
36+
gDelphiWrapper := TPyDelphiWrapper.Create(nil);
37+
gDelphiWrapper.Engine := gEngine;
38+
gDelphiWrapper.Module := gModule;
39+
40+
gEngine.LoadDll;
41+
except
42+
end;
43+
Result := gModule.Module;
44+
end;
45+
46+
initialization
47+
gEngine := nil;
48+
gModule := nil;
49+
gDelphiWrapper := nil;
50+
finalization
51+
gEngine.Free;
52+
gModule.Free;
53+
gDelphiWrapper.Free;
54+
end.
55+
56+
Binary file not shown.

‎Tutorials/Webinar II/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
![P4D Logo](https://github.com/pyscripter/python4delphi/wiki/Images/Python4Delphi-Libraries.png)
55

6-
- [Webinar Info]()
6+
- [Webinar Info](https://blogs.embarcadero.com/python-for-delphi-developers-webinar/)
77

8-
- [Video replay]()
8+
- [Video replay](https://blogs.embarcadero.com/combining-the-strengths-of-delphi-and-python/)
99

1010
- [Slides]()
1111

12-
- Source code is included in this folder. Demo33 is in the Demos directory and the python extension module demos are in the Modules directory.
12+
- Source code is included in this folder. [Demo33](https://github.com/pyscripter/python4delphi/tree/master/Demos/Demo33) is in the Demos directory and the python extension [module demos](https://github.com/pyscripter/python4delphi/tree/master/Modules/DemoModule) are in the Modules directory.
1313

1414
Please note that to compile the source code you need to install the [SVGIconLibrary](https://github.com/EtheaDev/SVGIconImageList).
15-
PyChartHTML uses the TEdgeBrowser control. So you need to use Delphi 10.4 or later and install the [WebView2 Runtime](https://developer.microsoft.com/en-us/microsoft-edge/webview2/). The required WebView2Loader.dll is already in the output folder. Finally the visualization and analytics demos make use of a range of python modules that need to be installed in python using the python package installer pip. These needed modules are listed below:
15+
PyChartHTML uses the [TEdgeBrowser](http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TEdgeBrowser_Component_and_Changes_to_the_TWebBrowser_Component) control. So you need to use Delphi 10.4 or later and install the [WebView2 Runtime](https://developer.microsoft.com/en-us/microsoft-edge/webview2/). The required WebView2Loader.dll is already in the output folder. Finally the visualization and analytics demos make use of a range of python modules that need to be installed in python using the python package installer pip. These needed modules are listed below:
1616

1717
- numpy
1818
- pandas

0 commit comments

Comments
 (0)
Please sign in to comment.