-
Content Count
1020 -
Joined
-
Last visited
-
Days Won
66
Posts posted by pyscripter
-
-
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.
-
20 minutes ago, Uwe Raabe said:Which platforms are in that project?
Win32 and Win64.
The problem was that the following was in the project file:
<PropertyGroup Condition="'$(Cfg_2)'!=''"> <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define> <Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File> </PropertyGroup>
which was overriding the platform settings. I don't know how this got into the project file. Project Magician was not cleaning it and this was overriding the platform settings. After deleting the Manifest line in the above, things seem to work as expected.
One more question. I have a build event defined for all configurations. Delphi keeps one replicating that for every configuration:
<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Win32'"> <PreBuildEvent/> <PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode> <PreLinkEvent/> <PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode> <PostBuildEvent>copy "$(BDS)\Redist\$(Platform)\WebView2Loader.dll" $(OUTPUTDIR) </PostBuildEvent> <PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode> </PropertyGroup>
The above is replicated for all configurations. Even when I manually delete the above from the project file manually, Delphi recreates it. Any idea why? Could that be cleaned up?
-
57 minutes ago, Uwe Raabe said:Correct! That is the setting that allows to set the custom manifest for all configurations.
In Project Magician options "Clear Application Settings" is set on by default.
But I still cannot set Manifest options for all configurations. How do I do that?
Update: RTDS
"All application settings in child configurations are removed and the base settings put in charge again. This effects the Icons, Manifest File, Output Settings and Appearance. Application settings are always platform based and thus the settings in the platform base configuration are the ones to be kept."
I need to set them for each platform.
-
Project Magician by @Uwe Raabe is such a great idea, but somehow every time I decide to use it, I end up regretting it.
This time the issue relates to custom manifest files. My project had one, but after activating Project Magician, saving and building my project this custom manifest file was not included. My application was released with a wrong manifest file.
I went to Project Options, set it again, save my project, close, open again, the setting disappeared.
What am I doing wrong? Delphi does not allow me to set the custom manifest for all configurations. It has to be set for each configuration individually.
-
A workaround for this python regression has been committed to the repo.
-
1
-
-
Is this a failure to load the python DLL or an error when executing python scripts?
Are you using the latest sources from the Github repo?
Also check out the following:
FindingPython · pyscripter/python4delphi Wiki (github.com)
MaskFPUExceptions · pyscripter/python4delphi Wiki (github.com)
If you are using python version 3.11.1 then please try with version 3.11.0 or earlier. There is a change related to the loading of dynamic libraries (dll) in 3.11.1, that I am looking into. See regression with latest Python 3.11.1 and _socket not found · Issue #100171 · python/cpython (github.com)
-
On 12/10/2022 at 7:20 PM, pyscripter said:iOS is supported.
For Android look at the Embarcadero fork.
Sorry. I meant iOS not supported.
I get value=none
in Python4Delphi
Posted · Edited by pyscripter
What did you expect to get?
Demo03 shows you how to use TPythonDelphiVar.