diff --git a/Modules/Delphi/Delphi.dpr b/Modules/Delphi/Delphi.dpr deleted file mode 100644 index 7ad17385..00000000 --- a/Modules/Delphi/Delphi.dpr +++ /dev/null @@ -1,32 +0,0 @@ -library Delphi; - -{ Important note about DLL memory management: ShareMem must be the - first unit in your library's USES clause AND your project's (select - Project-View Source) USES clause if your DLL exports any procedures or - functions that pass strings as parameters or function results. This - applies to all strings passed to and from your DLL--even those that - are nested in records and classes. ShareMem is the interface unit to - the BORLNDMM.DLL shared memory manager, which must be deployed along - with your DLL. To avoid using BORLNDMM.DLL, pass string information - using PChar or ShortString parameters. } - -uses - SysUtils, - Classes, - uMain in 'uMain.pas'; - -{$I Definition.Inc} - -exports - PyInit_Delphi; -{$IFDEF MSWINDOWS} -{$E pyd} -{$ENDIF} -{$IFDEF LINUX} -{$SONAME 'Delphi'} - -{$ENDIF} - -begin -end. - diff --git a/Modules/Delphi/Delphi.dproj b/Modules/Delphi/Delphi.dproj deleted file mode 100644 index 42373ec5..00000000 --- a/Modules/Delphi/Delphi.dproj +++ /dev/null @@ -1,108 +0,0 @@ - - - True - Library - Debug - None - Delphi.dpr - Win64 - {7E56095C-46B8-4F28-87A2-EEA8D9D2448D} - 19.1 - 3 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - Delphi - 00400000 - System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - 1033 - - - Debug - Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - - - Debug - Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - - - 0 - RELEASE;$(DCC_Define) - false - 0 - - - DEBUG;$(DCC_Define) - true - false - - - (None) - - - - MainSource - - - - Base - - - Cfg_1 - Base - - - Cfg_2 - Base - - - - Delphi.Personality.12 - - - - - Delphi.dpr - - - - - True - True - - - 12 - - - - diff --git a/Modules/Delphi/TestApp.py b/Modules/Delphi/TestApp.py deleted file mode 100644 index 1986ebcc..00000000 --- a/Modules/Delphi/TestApp.py +++ /dev/null @@ -1,25 +0,0 @@ -from Delphi import * - -class MainForm(Form): - - def __init__(self, Owner): - self.Caption = "A Delphi Form..." - self.SetBounds(10, 10, 500, 400) - self.lblHello = Label(self) - self.lblHello.SetProps(Parent=self, Caption="Hello World") - self.lblHello.SetBounds(10, 10, 300, 24) - self.OnClose = self.MainFormClose - - def MainFormClose(self, Sender, Action): - Action.Value = caFree - -def main(): - Application.Initialize() - Application.Title = "MyDelphiApp" - f = MainForm(Application) - f.Show() - FreeConsole() - Application.Run() - -main() - diff --git a/Modules/DelphiVCL/DelphiVCL.dpr b/Modules/DelphiVCL/DelphiVCL.dpr new file mode 100644 index 00000000..857e5b83 --- /dev/null +++ b/Modules/DelphiVCL/DelphiVCL.dpr @@ -0,0 +1,25 @@ +library DelphiVCL; + +uses + SysUtils, + Classes, + uMain in 'uMain.pas'; + +{$I Definition.Inc} + +exports + // This must match the pattern "PyInit_[ProjectName]" + // So if the project is named DelphiVCL then + // the export must be PyInit_DelphiVCL + PyInit_DelphiVCL; +{$IFDEF MSWINDOWS} +{$E pyd} +{$ENDIF} +{$IFDEF LINUX} +{$SONAME 'DelphiVCL'} + +{$ENDIF} + +begin +end. + diff --git a/Modules/DelphiVCL/DelphiVCL.dproj b/Modules/DelphiVCL/DelphiVCL.dproj new file mode 100644 index 00000000..a83e4c47 --- /dev/null +++ b/Modules/DelphiVCL/DelphiVCL.dproj @@ -0,0 +1,814 @@ + + + True + Library + Release + None + DelphiVCL.dpr + Win64 + {7E56095C-46B8-4F28-87A2-EEA8D9D2448D} + 19.1 + 3 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + DelphiVCL + 00400000 + System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + 1033 + + + Debug + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + + + Debug + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + + + 0 + RELEASE;$(DCC_Define) + false + 0 + + + DEBUG;$(DCC_Define) + true + false + + + (None) + + + + MainSource + + + + Base + + + Cfg_1 + Base + + + Cfg_2 + Base + + + + Delphi.Personality.12 + + + + + DelphiVCL.dpr + + + + + + + true + + + + + true + + + + + true + + + + + DelphiVCL.dll + true + + + + + 1 + + + 0 + + + + + classes + 1 + + + classes + 1 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + 1 + + + 1 + + + 0 + + + + + 1 + .framework + + + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 1 + + + 1 + + + + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + + + + 1 + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + + + + + + + + + + + True + True + + + 12 + + + + + diff --git a/Modules/DelphiVCL/TestVCL.py b/Modules/DelphiVCL/TestVCL.py new file mode 100644 index 00000000..fba8f36a --- /dev/null +++ b/Modules/DelphiVCL/TestVCL.py @@ -0,0 +1,45 @@ +from DelphiVCL import * + +class MainForm(Form): + + def __init__(self, Owner): + self.Caption = "A VCL Form..." + self.SetBounds(10, 10, 500, 400) + + self.lblHello = Label(self) + self.lblHello.SetProps(Parent=self, Caption="Hello Python") + self.lblHello.SetBounds(10, 10, 300, 24) + + self.edit1 = Edit(self) + self.edit1.SetProps(Parent=self) + self.edit1.SetBounds(10, 30, 250, 24) + + self.button1 = Button(self) + self.button1.Parent = self + self.button1.SetBounds(270,24,100,30) + self.button1.Caption = "Add" + self.button1.OnClick = self.Button1Click + + self.lb1 = ListBox(self) + self.lb1.Parent = self + self.lb1.SetBounds(10,60,300,300) + + self.OnClose = self.MainFormClose + + def MainFormClose(self, Sender, Action): + Action.Value = caFree + + def Button1Click(self, Sender): + self.lb1.Items.Add(self.edit1.Text) + self.edit1.Text = "" + +def main(): + Application.Initialize() + Application.Title = "MyDelphiApp" + f = MainForm(Application) + f.Show() + FreeConsole() + Application.Run() + +main() + diff --git a/Modules/Delphi/uMain.pas b/Modules/DelphiVCL/uMain.pas similarity index 55% rename from Modules/Delphi/uMain.pas rename to Modules/DelphiVCL/uMain.pas index 96186301..06d82d7a 100644 --- a/Modules/Delphi/uMain.pas +++ b/Modules/DelphiVCL/uMain.pas @@ -1,49 +1,56 @@ -unit uMain; - -interface - -uses PythonEngine; - -function PyInit_Delphi: PPyObject; cdecl; - -implementation - -uses WrapDelphi, WrapDelphiVCL; - -var - gEngine : TPythonEngine; - gModule : TPythonModule; - gDelphiWrapper : TPyDelphiWrapper; - -function PyInit_Delphi: PPyObject; -begin - try - gEngine := TPythonEngine.Create(nil); - gEngine.AutoFinalize := False; - gEngine.UseLastKnownVersion := False; - // Adapt to the desired python version - gEngine.RegVersion := '3.8'; - gEngine.DllName := 'python38.dll'; - - gModule := TPythonModule.Create(nil); - gModule.Engine := gEngine; - gModule.ModuleName := 'Delphi'; - - gDelphiWrapper := TPyDelphiWrapper.Create(nil); - gDelphiWrapper.Engine := gEngine; - gDelphiWrapper.Module := gModule; - - gEngine.LoadDll; - except - end; - Result := gModule.Module; -end; - -initialization -finalization - gEngine.Free; - gModule.Free; - gDelphiWrapper.Free; -end. - - +unit uMain; + +interface + +uses PythonEngine; + +function PyInit_DelphiVCL: PPyObject; cdecl; + +implementation + +uses WrapDelphi, WrapDelphiVCL; + +var + gEngine : TPythonEngine; + gModule : TPythonModule; + gDelphiWrapper : TPyDelphiWrapper; + +// This must match the pattern "PyInit_[ProjectName]" +// So if the project is named DelphiVCL then +// the function must be PyInit_DelphiVCL +function PyInit_DelphiVCL: PPyObject; +begin + try + gEngine := TPythonEngine.Create(nil); + gEngine.AutoFinalize := False; + gEngine.UseLastKnownVersion := False; + // Adapt to the desired python version - Will only work with this version + gEngine.RegVersion := '3.9'; + gEngine.DllName := 'python39.dll'; + + gModule := TPythonModule.Create(nil); + gModule.Engine := gEngine; + // This must match the ProjectName and the function name pattern + gModule.ModuleName := 'DelphiVCL'; + + gDelphiWrapper := TPyDelphiWrapper.Create(nil); + gDelphiWrapper.Engine := gEngine; + gDelphiWrapper.Module := gModule; + + gEngine.LoadDll; + except + end; + Result := gModule.Module; +end; + +initialization + gEngine := nil; + gModule := nil; + gDelphiWrapper := nil; +finalization + gEngine.Free; + gModule.Free; + gDelphiWrapper.Free; +end. + + diff --git a/Tutorials/Webinar II/Python for Delphi Developers II.pdf b/Tutorials/Webinar II/Python for Delphi Developers II.pdf new file mode 100644 index 00000000..a82cc735 Binary files /dev/null and b/Tutorials/Webinar II/Python for Delphi Developers II.pdf differ diff --git a/Tutorials/Webinar II/README.md b/Tutorials/Webinar II/README.md index a6909f44..542c2ef2 100644 --- a/Tutorials/Webinar II/README.md +++ b/Tutorials/Webinar II/README.md @@ -3,16 +3,16 @@ ![P4D Logo](https://github.com/pyscripter/python4delphi/wiki/Images/Python4Delphi-Libraries.png) -- [Webinar Info]() +- [Webinar Info](https://blogs.embarcadero.com/python-for-delphi-developers-webinar/) -- [Video replay]() +- [Video replay](https://blogs.embarcadero.com/combining-the-strengths-of-delphi-and-python/) - [Slides]() -- Source code is included in this folder. Demo33 is in the Demos directory and the python extension module demos are in the Modules directory. +- 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. Please note that to compile the source code you need to install the [SVGIconLibrary](https://github.com/EtheaDev/SVGIconImageList). -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: +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: - numpy - pandas