KoRiF
Members-
Content Count
32 -
Joined
-
Last visited
Community Reputation
1 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
in order to untangle the tangle, first take a look at reg_env.bat and how the EXEC variable is initialized and used It’s difficult to answer in absentia, but it looks like an incorrect initialization of some parameter on your side, an environment variable, or a bug in the component itself try updating to the latest version, and then check the settings, explicitly specifying directories wherever possible
-
Hi, your issue is from here : snim0e = re.search(r"SNlM0e\":\"(.*?)\"", resp.text) check your "resp" value and does it fits to regular expression as expected generally speaking, your problem may have nothing to do with Delphi anyway, debugging is required on the python side to determine the cause have you read the Authentification section? (tools like Postman can also help)
-
i think the first step you have to do is to convert to numpy array that supports memory buffer protocol This means that you will be able to operate on data in memory as if it were a C array. The next tricky step is to pass this array to Object Pascal which depends on your architecture and needs. For example, you could use the SharedMemory approach as the most universal The last step is parse your memory buffer on Delphi side
-
How to pass a callback function from Pascal as a parameter to a Python function?
KoRiF replied to Heimo's topic in Python4Delphi
Does TPythonModule.Events can help to resolve your problem? -
I'm afraid to add a submodule you have to go beyond Python4Delphi components and use Python C-API try to study how the TPythonModule instance is created and act similarly You will need to modify this approach someway to add the submodule entry to the dictionary for the supermodule: try use PythonEngine.PyModule_GetDict(PythonModule.Module) https://github.com/pyscripter/python4delphi/blob/1cd66211f586468d9fe3a1352344073759e64d8a/Source/PythonEngine.pas#L3655 Check also: https://github.com/pyscripter/python4delphi/blob/master/Source/PythonEngine.pas#L3649 https://python.readthedocs.io/en/stable/c-api/import.html?highlight=pyimport_getmoduledict#c.PyImport_GetModuleDict https://python.readthedocs.io/en/stable/c-api/import.html#c.PyImport_AddModuleObject this will require some experimentation, but I hope you succeed
-
I think the best you can is to refer to the PythonEngine's DoRedirectIO sources the line sys.stdin=sys.stderr=sys.stdout=DebugOutput() redirects error output onto PythonEngine.IO so far you could try to use other redirection somewhere in your code Hope this helps
-
You could consider direct use of OpenCV for Delphi depending on your task and supposed "ecosystem". This is live project with working examples. There is also experimental version of OOP-oriented OpenCV Usage of P4D-Data-Scinces does not preclude you from using Python in a script style. If you can deal with some namespace confusion ("global" python variables and functions are actually accessible on Delphi side via the name of the corresponding modules available via BuiltinModule() and MainModule(), you can experiment with print(dir(...)) ) then you may well use some mix (and in some cases even be forced to use it) - although this may not be the best idea if done haphazardly If you are strong in C++ you can try use OpenCV in Delphi through C++Builder intermediate adapter
-
No, not quite, but it was your link that helped me unravel the tangle and find the required solution. So thank you very much!!! My current solution is: Create field that contains reference to function that will be called a-la lambda later Create cdecl Delphi method that wraps the call of the "lambda" field with cdecl convention In the module initialization event handler initialize "lambda" field by a stub and add cdecl Delphi method-wrapper to the module under the name that cannot be just a 'lambda' for some odd reason Create method that evaluates added delphi method as python callable object Assign "lambda" field with an anonymous Delphi method Evaluate added Delphi method that wraps "lambda" as python callable object Pass evaluated python callable object as python callable parameter Repeat steps (5) - (7) in other place if necessary In order to emulate several "lambdas" simultaneously, we would need to maintain something like a dictionary on the python side And yes, strictly speaking, this is neither a lambda nor on the Delphi side (in Delphi there is no pure concept of a lambda at all, and even a very close "anonymous method" term poorely suited due to, ironically, our callable object is renamed several times here), nor on the python side (it's just a permanent object of a named python function there) However, I use the term "lambda" because it fits the problem well conceptually: we wanted to define our callable at the call site, and in terms of the top-level algorithm (not the implementation), we achieved this This mostly works as expected, although for some other use cases I faced with unexpected issues in argument parsing. However, these issues are likely outside the scope of the question. Memory leaks are still relevant for such "lambda emulation" and this is an important aspect since calls can be repeated thousands of times so need to be careful Many thanks again!
-
You have to install every of dcl***.dpk But first you must install foundation libraries as said there: PythonEnviroments allows effectively manage [embedded] Python environments Lightweight-Python-Wrappers allows easily wrap any python library as Delphi component and easily use it in any Object Pascal project Read this for more concept understanding
-
get well & be healthy!
-
Try this. With proper installation of the whole stack of components, this should solve your problem automatically
-
In my opinion your problem may also be thread synchronization I don't know how the Telegram library is implemented in Python it may well be that the output will still work, but after the bot stops and your application has time to close so you don't see the output take a look at the DelayWrites and RawOutput properties of TPythonGUIInputOutput and try playing with this also, take a look at the examples of triggering event handling in Delphi and try to use it for debugging (set breakpoint there) See more examples in P4D Tutorials Hope this helps
-
you need to make sure your script is running at all, try running something a-la helloworld first if does not, then the problem may be in the "wrong" python, so you would have to explicitly set the paths to python dll file in the properties of the PythonEngine Alternatively you can check some example working with fast-Telega-based TelegramBot (voice-oriented messaging). Hope, this helps.
-
Passing a python object to a delphi function parameter
KoRiF replied to iqrf's topic in Python4Delphi
This stuff may be a bit less straightforward: https://github.com/pyscripter/python4delphi/blob/master/Tutorials/Webinar I/ModuleDemo/MainForm.pas#L126 Please check this: Webinar Hope this helps. P.S. this can clear rather odd arg parsing syntax: https://docs.python.org/3/c-api/arg.html -
Beginner to Delphi. Have no idea what I'm doing wrong here
KoRiF replied to Willicious's topic in Delphi IDE and APIs
please write to me directly if you are still interested