-
Content Count
920 -
Joined
-
Last visited
-
Days Won
56
Everything posted by pyscripter
-
Structural highlighting has also been added. Technical details.
-
Using Python4Delphi library in a Windows service
pyscripter replied to Luca Pretti's topic in Python4Delphi
In the demo project modify the CreateEngine function as follows: procedure TService1.CreatePyEngine; begin PythonEngine := TPythonEngine.Create(nil); PythonEngine.Name := 'PythonEngine'; PythonEngine.DLLName := 'python313.dll'; PythonEngine.DllPath := 'c:\python\python313\'; PythonEngine.PythonHome := PythonEngine.DLLPath; PythonEngine.VenvPythonExe := PythonEngine.DLLPath + 'python.exe'; // may be needed PythonEngine.RegVersion := '3.13'; PythonEngine.UseLastKnownVersion := False; PythonEngine.FatalAbort := False; PythonEngine.FatalMsgDlg := False; PythonEngine.LoadDll; TPythonThread.Py_Begin_Allow_Threads; end; I think this should set the python path correctly and avoid import errors. -
Using Python4Delphi library in a Windows service
pyscripter replied to Luca Pretti's topic in Python4Delphi
What I think is best: - Create the pythonEngine (or load the python dll) on Start - Destroy the pythonEngine (or unload the python dll) on Stop - Follow these guideliines to execute python code in threads. Please see the attached project for an example that does that. Sample log output after starting and stopping the engine: Logs From Background Thread: 24/10/2024 14:49:18 Python eval = 4 Logs From Background Thread: 24/10/2024 14:49:19 Python eval = 4 Logs From Background Thread: 24/10/2024 14:49:20 Python eval = 4 Logs From Background Thread: 24/10/2024 14:49:21 Python eval = 4 Service.zip -
I very much like the "Filter Explicit properties" expert. However, in recent versions of Delphi (not sure when it started), the IDE inserts annoying DesignSize properties that "pollute" the Dfm and the revision history. It would be really nice if the expert was renamed "Filter DFM properties" and included the option of removing these DesignSize properties.
- 11 replies
-
Feature enhancement request - Filter DFM properties
pyscripter replied to pyscripter's topic in GExperts
The understatement of the year.- 11 replies
-
Delphi 12.2 is now available for download from https://my.embarcadero.com/.
-
Using Python4Delphi library in a Windows service
pyscripter replied to Luca Pretti's topic in Python4Delphi
When you run as a service the registry information is not available. You need to do something like: procedure TService1.CreatePyEngine; begin PythonEngine := TPythonEngine.Create(nil); PythonEngine.Name := 'PythonEngine'; PythonEngine.DLLName := 'python313.dll'; PythonEngine.DllPath := 'c:\pathtoyourpythonhome\'; PythonEngine.RegVersion := '3.13'; PythonEngine.UseLastKnownVersion := False; PythonEngine.FatalAbort := False; PythonEngine.FatalMsgDlg := False; PythonEngine.LoadDll; end; I have tested and it works. -
Do you have any code you can share?
-
I am also sceptical. However, I see that in one of the most starred Github Delphi repos, danieleteti/delphimvcframework: DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development., the IDE expert project generator, includes MSHeap by default. @Daniele TetiCould you please enlighten us as to what led you to this choice? By the way the RTL can be configured to use MSHeap, if compiled with the SIMPLEHEAP conditional define. The downside is that ReportMemoryLeaksOnShutdown is not available with MSHeap.
-
This is the unit @Stefan Glienke was referring to. 100 lines and it uses no other unit!
-
Set UseWindowConsole to True and in the FormCreate add: ShowWindow(GetConsoleWindow, SW_HIDE);
-
It is a bit tricky to run multiprocessing from P4D. For instance with Demo01: - Set VenvPythonExe to the appropriate python.exe path e.g. 'c:\python\python313\python.exe' - If you are printing from the processes and you want to see the output set UseWindowsConsole to True. In your script there is no printing from the processes. - Add to the above script as first statement: __file__ = file_path - Save your script to that filepath - Run the demo and exec your script.
-
suggestion for server side command execution on Linux
pyscripter replied to dummzeuch's topic in Network, Cloud and Web
This is just to say that pyscripter/Ssh-Pascal: Delphi ssh library wrapping libssh2 (github.com) includes binaries that do not require OpenSSL, but use Windows CNG instead. It also includes scripts that make it very easy to update the binaries. -
Please see the blog post and watch the videos! Although the videos show PyScripter, the underlying editor control is SynEdit. Note: Development of SynEdit has moved back to pyscripter/SynEdit: SynEdit is a syntax highlighting edit control, not based on the Windows common controls. (github.com) for the reasons explained here. The multi-caret developments are in the multicaret branch, which will be merged to master after a period of testing. It is quite solid, but if you would like to try and help iron out bugs, that would be much appreciated.
-
SynEdit now supports mulit-caret, multi-selection editing
pyscripter replied to pyscripter's topic in I made this
In case you want to influence future development of SynEdit, vote in this poll. -
Please see Delphi 12.2 available for download - Delphi IDE and APIs - Delphi-PRAXiS [en] (delphipraxis.net)
-
Strange, since in my case both GExperts and MMX (v15.1.11) worked fine after installing the patch. So did all components installed from source in Delphi 12.
-
I have a user on Win7 reporting that the background color of VirtualTreeViews is black under any theme in Win7. The app is compiled with Delphi 12 and the master branch of VT. Earlier versions compiled with Delphi 11 and older version of VT appear to work fine. Is anyone aware of Vcl Styles issues in Win7? Was there any changes in Delphi 12 or VirtualTreeView that may have had an impact on this?
- 1 reply
-
- vcl_styles
- win7
-
(and 1 more)
Tagged with:
-
The issue was resolved when the user enabled Aero themes. So, please ignore the question above.
- 1 reply
-
- vcl_styles
- win7
-
(and 1 more)
Tagged with:
-
Does the main form's OnShow event only ever fire once?
pyscripter replied to Gord P's topic in General Help
First statement in my FormShow method. // Do not execute again OnShow := nil; -
SynEdit now supports mulit-caret, multi-selection editing
pyscripter replied to pyscripter's topic in I made this
Main Issues with the Delphi editor: Unicode handling The most serious issue with the Delphi editor IMHO is proper Unicode handling. It has issues with surrogate pairs. combining characters etc. Try for instance to paste ḱṷṓn to the editor. Even wide Unicode characters have wrong spacing (e.g. 爾雅爾雅爾雅爾雅爾雅爾雅). Let alone of course the handling of emojis, bi-directional text etc. Missing standard code editor behaviour Handle triple and quadruple clicks for selection Double click and drag should select whole words Triple click and drag should select line The track changes bar does not play correctly with undo redo Missing many nice-to-have features common in other code editors Multi-caret editing Move/Duplicate lines commands HTML copy/paste to copy code with syntax highlighting to other apps Alpha-blending of selection OLE drag & drop Support for font ligatures etc. SynEdit now has first-class Unicode support based on DirectWrite, multi-caret editing, all other features from the list above and much more. It is also very fast and responsive, but of course there is a lot of scope for performance optimizations. -
As I said, I have no experience of using these components. But if you look at P4D-Data-Sciences/demos/PyTorch/PyTorchTimeSequencePrediction/MainForm.fmx at 551db5923fad9a9e8384169233dd64ddf9f87d12 · Embarcadero/P4D-Data-Sciences (github.com) you will see that a PythonEnvironments addon EnsurePip is used.
-
It is part of Embarcadero/P4D-Data-Sciences: A collection of lightweight Python wrappers based on Python4Delphi simplifying Data Sciences development with Delphi (github.com) This is a similar project to Embarcadero/PythonPackages4Delphi: General collection of Python Packages wrapped for use in Delphi and C++Builder (github.com) and uses the same infrastructure. You need to have a similar setup for using moviePy to the PyTorch sample. These repos have been developed and are being maintained by Embarcadero. I am not involved in them and have never used them. You should direct your questions and issues to the respective repos.
-
Did you have a look at the sample I pointed out above?
-
CreateComponent() equivalent for non-component classes?
pyscripter replied to eivindbakkestuen's topic in Python4Delphi
The recommended way to expose classes is to use TPyClassWrapper<T: class>. If for example you have a class TMyClass you want to expose to python, you can use the above from unit wrappers as follows: PyDelphiWrapper1.RegisterDelphiWrapper(TPyClassWrapper<TMyClass>); or at runtime (e.g. inside the FormCreate handler: PyDelphiWrapper1.RegisterDelphiWrapper(TPyClassWrapper<TMyClass>).Initialize; If you want your class to capable of being instantiated from python then do: TMyClassWrapper = class(TPyClassWrapper<TMyClass>) constructor CreateWith(APythonType: TPythonType; args, kwds: PPyObject); overload; override; end; constuctor TMyClassWrapper.CreateWith(APythonType: TPythonType; args, kwds: PPyObject); begin Create(APythonType); DelphiObject := TMyClass.Create; end; and in the FormCreate handler: PyDelphiWrapper1.RegisterDelphiWrapper(TMyClassWrapper).Initialize; In your python script you can then create instances using the pythonic from delphi_module import MyClass obj = MyClass() With TStringList is a bit more complicated since the superclass TStrings has already been exposed. To maintain the TStrings functionality you need to do the following: type TStringListWrapper = class(TPyDelphiStrings) private function GetDelphiObject: TStringList; procedure SetDelphiObject(const Value: TStringList); public constructor CreateWith(APythonType: TPythonType; args, kwds: PPyObject); overload; override; class function DelphiObjectClass : TClass; override; class procedure RegisterMethods( PythonType : TPythonType ); override; class procedure RegisterGetSets( PythonType : TPythonType ); override; // Properties property DelphiObject: TStringList read GetDelphiObject write SetDelphiObject; end; class function TStringListWrapper.DelphiObjectClass: TClass; begin Result := TStringList; end; function TStringListWrapper.GetDelphiObject: TStringList; begin Result := inherited DelphiObject as TStringList; end; class procedure TStringListWrapper.RegisterGetSets(PythonType: TPythonType); begin // Do not call inherited end; class procedure TStringListWrapper.RegisterMethods(PythonType: TPythonType); begin // Do not call inherited end; procedure TStringListWrapper.SetDelphiObject(const Value: TStringList); begin inherited DelphiObject := Value; end; constructor TStringListWrapper.CreateWith(APythonType: TPythonType; args, kwds: PPyObject); begin Create(APythonType); DelphiObject := TStringList.Create; end; and in the FormCreate handler: PyDelphiWrapper1.RegisterDelphiWrapper(TStringListWrapper).Initialize; You can then use it in your python scripts as follows: from delphi_module import StringList sl = StringList() sl.Add("abc") print(sl[0])