-
Content Count
1001 -
Joined
-
Last visited
-
Days Won
64
Posts posted by pyscripter
-
-
56 minutes ago, IJCdelpi said:if PyArg_ParseTuple(Args, 'i:read_AP_register', @arg1, @arg2) <> 0
It should be 'ii:read_AP_register' if you are expecting two integer arguments.
-
1
-
-
-
-
1 minute ago, aehimself said:All my breakpoints just become unavailable (like code never gets executed in that function), did you meet the same issue?
Yes.
-
FWIW, I have tried the unofficial LSP patches and I could no longer debug programs. So I went back to the original dlls and debugging was available again.
-
1
-
1
-
-
On 1/14/2023 at 8:12 PM, uefi said:Hello, I can not get the result of the script execution instead of the result I get:
value=none
What did you expect to get?
Demo03 shows you how to use TPythonDelphiVar.
-
8 hours ago, uefi said:I still don’t understand how you did it and where to insert it
Py_Begin_Allow_Threads; and Py_End_Allow_Threads;Use Demo 33 as a guide. As @David Heffernan said running python in threads is not trivial and unlikely to save you time.
-
FPyModule.Name := '__main__';
meeds to be
FPyModule.ModuleName := '__main__';
Better to call your module something else (delphimodule or anything else. in the demos 'spam' is used) and import that module.
-
9 minutes ago, Juan C.Cilleruelo said:After visualizing all the video tutorials, seeing the demos, and seeing what kind of support the components have, I'm seriously thinking of abandoning this line of investigation.
Please do. You will do everyone a favour.
-
Call you delphi module say "delphimodule" and in your script:
import delphimodule
print(delphimodule.QUANTITY);
or
from delphimodule import QUANTITY
print(QUANTITY)
Please look at the demos, before asking questions here and do yourself a favour. Do watch the two video tutorials. It is only two hours viewing and will save you masses of time if you plan to do any serious work with P4D.
-
38 minutes ago, Juan C.Cilleruelo said:FPyModule.Name := '__main__';
Also do not call the module __main__. This is name is reserved for the main python module.
-
37 minutes ago, Juan C.Cilleruelo said:FPyModule.Initialize;
There is no need for that. It has already been initialized.
-
17 minutes ago, Juan C.Cilleruelo said:I'm still fighting with the version of non-visual components.
Create and link all non-visual components before you call LoadDLL.
-
10 minutes ago, Juan C.Cilleruelo said: PyEngine.LoadDll;
p := PyEngine.PyLong_FromLong(1);
PyModule.SetVar('QUANTITY', p);
PyEngine.Py_DecRef(p);PyEngine.IO := FPythonIO;
Set PyEngine.IO before you call LoadDLL
Redirection is setup by TPythonEngine.Initialize, which is called by LoadDLL.
-
9 minutes ago, Fr0sT.Brutal said:so - ?
You can use TPythonInputOutput event handlers to log python output to file or produce output in a console application.
-
15 minutes ago, Juan C.Cilleruelo said:I will continue looking for the methods delegate component of Delphi's methods inside the Python Script.
Watching the video tutorials I have pointed out and looking at the respective demos, would save you a lot of time.
-
-
In a 5 year old answer to a stackoverflow question @David Heffernan responded that "class properties cannot be accessed via RTTI". Is this still the case with recent versions of Delphi?
-
1
-
-
4 hours ago, Talal Bader said:not sure if this is caused by different versions or I am missing something. but indeed it is better way of doing it 🙂
I was just writing code from memory without testing. What you did is fine.
-
1
-
-
By the way, an easier way is to use PythonVersions.
var PyVersion := PythonVersionFromPath('C:\MyApps\MConda38\envs\pg\'); PythonEngine1.Assign(PyVersion); PythonEngine1.LoadDLL;
-
- You should not set VenvPythonExe. This is for environments created with venv and not Conda.
- The DLLName should be set before you call LoadDLL (e.g. in FormCreate)
- SetPythonHome: It should be called with the same directory as the DLLPath
You may have to add the DLLPath to the environment path.
-
P4D works fine with miniconda distributions. Read FindingPython · pyscripter/python4delphi Wiki (github.com) for details.
1 hour ago, superc said:I Download embeddable version of Python 3.10.8 and copy *.dll and python310.zip
There is no need to do that. If on the other hand you want to deploy python with your application, have a look at this project Embarcadero/PythonEnviroments: Components to simplify the deployment for Python environments for Delphi applications using Python4Delphi. (github.com)
-
10 minutes ago, programmerdelphi2k said:just unchecking "Inherit" (on Event) does not works?
If you uncheck the event inherit in derived configurations, then you would need to define it again.
The question is why Delphi replicates an event defined for All Configurations for each configuration and how you can prevent that.
-
6 minutes ago, Uwe Raabe said:OK, I will try to reproduce. Which Delphi version are we talking about?
Alexandria with patches.
Best Practice Question: Bidirectional EXE-to-EXE communication
in RTL and Delphi Object Pascal
Posted · Edited by pyscripter
The IPC unit based on named pipes created by Russell Libby in 2003 and updated by @FPiette is worth checking.
Blog article: Behind the connection: Inter Process Communication Using Pipes (francois-piette.blogspot.com)
Source code: OverByte - Blog Source Code
Named pipes in overlapped mode are super efficient and faster than sockets. See Synchronous and Overlapped Pipe I/O - Win32 apps | Microsoft Learn. See also I/O Completion Ports - Win32 apps | Microsoft Learn. I have contributed such a solution to the python library RPyC and it beats the socket based IPC by a large margin. The downside is that it is Windows only.