-
Content Count
1020 -
Joined
-
Last visited
-
Days Won
66
Posts posted by pyscripter
-
-
1 hour ago, David Heffernan said:And then you can add simple memory leaks on shutdown reporting.
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.
-
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.
-
3
-
-
38 minutes ago, Stefan Glienke said:DelphiAST has the option to use one for its parsing
This is the unit @Stefan Glienke was referring to. 100 lines and it uses no other unit!
-
3
-
-
2 hours ago, maomao2028 said:Great, it works.
Can the console window be hidden when the program is running?
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.
-
3 hours ago, dummzeuch said:I just got the sources, downloaded the libssh2 and openssl dlls
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.
-
1
-
1
-
-
-
13 minutes ago, RDP1974 said:I have not removed parnassus plugins
now on this win11 24h2 the setup won't complete, both web install or iso
Please see Delphi 12.2 available for download - Delphi IDE and APIs - Delphi-PRAXiS [en] (delphipraxis.net)
-
1
-
-
2 hours ago, Ian Branch said:It is also a breaking change for all those 3rd Party libraries that you get their source code for and install by building their files.
I have spent a couple of hours rebuilding libraries I had the source for that needed to be re-installed as, presumably, their existing .bpl/.dcp/.dcu files were no longer compatible.
Also the existing installed plug-ins - GExperts, Eurekalog, MMX & cnWizards won't load.
I rebuilt GExperts and is OK but I will have to wait for the other 3.
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.
-
The issue was resolved when the user enabled Aero themes. So, please ignore the question above.
-
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?
-
2 hours ago, FredS said:Simpler just to add a FirstShown Property.
First statement in my FormShow method.
// Do not execute again OnShow := nil;
-
1
-
-
On 10/11/2024 at 3:11 AM, Vincent Parrett said:I wish the Rad Studio editor had this functionality
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
- 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.
-
1
-
3
-
Unicode handling
-
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.
-
11
-
1
-
-
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.
-
4 hours ago, Walid Alg said:Yes, I did. It didn’t work for me due to the absence of PyTorch, I don't know which library it is in,
It is part of
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?
-
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])
-
-
Dependencies:
Please make sure the following are installed before installing this library and in the following order:
Each library depends on the one above it, once these are installed this library will also install
-
To automatically deploy python modules you need to use these related projects:
The second one already contains the wrapped MoviePy python package.
-
1
-
1
-
-
17 minutes ago, Celebr0 said:I don’t understand how and where initialization is performed, you should know this
You do not need to understand anything, Just place a breakpoint on the Initialize statement and after the debugger stops there, keep pressing F7 (step in) until the error occurs.
Anyway, I have downloaded the embedded version of python 3.12.6 64bits from https://github.com/adang1345/PythonWin7, extracted the zip file in a directory
Quotec:\python-3.12.6-embed-amd64
and used the following properties in PythonEngine:
DllPath C:\python-3.12.6-embed-amd64
PythonEngine.RegVersion : 3.12
PythonEngine.DllName : python312.dll
PythonEngine.UseLastKnownVersion : FalseIt seems to work fine on a Windows 11 machine. You can try the same on your windows 7 machine.
-
So why don't you step in Initialize?
Using Python4Delphi library in a Windows service
in Python4Delphi
Posted
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.