-
Content Count
983 -
Joined
-
Last visited
-
Days Won
62
Everything posted by pyscripter
-
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]) -
Also have a look at this sample from https://github.com/Embarcadero/P4D-Data-Sciences/.
-
Dependencies: Please make sure the following are installed before installing this library and in the following order: Python4Delphi PythonEnvironments Lightweight-Python-Wrappers 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: Embarcadero/Lightweight-Python-Wrappers: Lightweight Wrappers based on Python4Delphi to make it easy to import Python modules into Delphi components. (github.com) Embarcadero/PythonPackages4Delphi: General collection of Python Packages wrapped for use in Delphi and C++Builder (github.com) Embarcadero/P4D-Data-Sciences: A collection of lightweight Python wrappers based on Python4Delphi simplifying Data Sciences development with Delphi (github.com) The second one already contains the wrapped MoviePy python package.
-
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 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 : False It 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?
-
Just step into LoadDLL and observe where exactly the error occurs. I am not a magician. As I said, python 3.12 + windows 7 + delphi XE2 is not supported by python and by P4D. If you can come up with a fix I would consider implementing it.
-
Possibly. There have been a lot of changes in the last six months. I am afraid support for running unofficial newer versions of python on Windows 7 is outside the scope of the P4D project. It might help though if you debug and report at which exact point the error occurs.
-
That's why we debug programs stepping through the code, To know exactly where the error occurs. And what do you mean crash? Cannot you debug and step into LoadDLL? Or set FatalMsgDlg to True and FatalAbort to False. Do you get an error message? Most likely the python dll fails to load. The most common reason: Are you compiling for 64bits? For more details please read FindingPython · pyscripter/python4delphi Wiki (github.com) Also, could you update python to 3.12.3 and see whether it makes a difference? Needless to say that I cannot reproduce the issue here.
-
There is no such code in P4D. Instead: PyWideStringList_Append(PWSL, PWCharT(StringToWCharTString(Paths[I]))); Your code sample above makes no sense. SplitString returns a string array. So code like this: writeln(PansiChar(ansistring(ar))); should contain array indices (e.g. ar[1]). And in any case that code is only executed if you try to set the python path and has been around for quite a while. It is not executed for example by any of the demos. With the latest change Demo36 should work without issues. Again please provide a minimal project that produces errors.
-
This was not related to the latest revisions. There was an issue in the Demo related to PythonEngine being destroyed before the threads terminated. This is now fixed in version control. Please try with the latest release and report if the issue has been fixed.
-
Which version of P4D are you using? Getit or github and if the latte from which repo? Which version of python? Could you post a minimal project that reproduces the crash?
-
You need to deploy python to the Android device for this to work. Please see: Embarcadero/PythonEnvironments: Components to simplify the deployment for Python environments for Delphi applications using Python4Delphi. (github.com) and PythonEnvironments/samples/environments/deploy/sample_06_SimpleAndroid at main · Embarcadero/PythonEnvironments (github.com)
-
As mentioned above, 12.2 works correctly at 300%, But maybe there is an issue when running inside a VM.