-
Content Count
103 -
Joined
-
Last visited
Everything posted by Juan C.Cilleruelo
-
Does ChatAI make StackOverflow obsolete ?
Juan C.Cilleruelo replied to david_navigator's topic in Tips / Blogs / Tutorials / Videos
I think that OpenIA needs Stackoverflow as the feed of his responses. Because OpenIA is not able to investigate the solutions. Only can locate and infer what is the most accurate response. To be sure that the response is the most accurate, it needs many wrong responses, which are the most frequent in StackOverflow. -
I deployed python as unregistered. (i.e., embedded) No problems with this approach.
-
Are you asking about the deployment of the final application? This is, how to install Python with your application?
-
I have in my plans the use of PyVista inside a Delphi application. I'm currently using OpenSCAD to draw my graphics, but I think PyVista will be a better solution. But, I still have not initiated searching for this idea's viability. Have you advanced something in this field? I need to achieve the rendering of surfaces and more speed in the drawing. Do you think this is possible?
- 2 replies
-
- pyvista
- datavisualization
-
(and 1 more)
Tagged with:
-
Welcome to the unique forum in the world, whose members will try to understand you, with the goal of helping you to solve some of your problems! Good luck with your search for help! (sincerely)
-
This discussion can be helpful for you: Stackoverflow ask about parsing formulas with Python As you can see, it always recovers the result of the formula into a variable.
-
You probably need a Math Parser component. The goal of a scripting language is not this. I think that Python doesn't have this concept of "result." If anyone can confirm or deny this affirmation, please do. With a Scripting language you need to assign your result to a variable and after take the value of this variable from Delphi.
-
Try this method. I've tried to document it over the code. I do not use TPythonDelphiVar because have some connotations of visual components that we don't need. This example assumes you know the type of the variable whose value you want to recover. procedure TForm1.Button1Click(Sender: TObject); var PythonEngine :TPythonEngine; PythonModule :TPythonModule; Pointer :PPyObject; //Pointer to create a value inside the Engine. VarColor :Variant; //Variant to recover the Color from the Engine PasColor :string; //The color in Pascal. begin PythonEngine := TPythonEngine.Create(nil); {Documentation explains that these properties are for Embedded (not registered) installations of Python } PythonEngine.AutoLoad := False; PythonEngine.DllName := 'python311.dll'; PythonEngine.DllPath := 'C:\Views\senCille\bin\Win64\Python'; PythonEngine.APIVersion := 1013; PythonEngine.RegVersion := '3.11'; PythonEngine.UseLastKnownVersion := False; PythonEngine.SetPythonHome('C:\Views\senCille\bin\Win64\Python'); {We create a Module that points to a special one inside PythonEngine} PythonModule := TPythonModule.Create(nil); PythonModule.Engine := PythonEngine; PythonModule.ModuleName := '__main__'; try PythonEngine.LoadDll; {Now we are going to create a Variable inside PythonEngine} {p point to and Unicode string created inside the PyEngine} Pointer := PythonEngine.PyUnicode_FromString('Dark Blue'); {Create the Variable Color inside PythonEngine and assigns p as his value} PythonModule.SetVar('Color', Pointer); {At this moment, the value pointed by p has two references: Pointer : a pointer inside the Delphi source and Color : The variable inside PythonEngine. We call Py_DecRef to decrement this counter and allow PythonEngine to free this variable when not more need it} PythonEngine.Py_DecRef(Pointer); {We use a python script to assign a value to Color instance inside PythonEngine} PythonEngine.ExecString('Color = "Dark Blu"'); {Now we retrieve a PythonEngine value contained in Color variable} VarColor := PythonModule.GetVarAsVariant('Color'); {if the local variant don't have a value, we assign on by default} if not (VarColor = unassigned) then begin {We can use the Variant in our program, but we prefer a string type} PasColor := VarColor; end else PasColor := 'No color Assigned'; ShowMessage('Value = ' + PasColor); finally PythonModule.Free; PythonEngine.Free; end; end; DemoVar.zip
-
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo posted a topic in Python4Delphi
I've seen the EvalScript method and the ExecuteScript method of the TPythonEngine component. I need to get from Delphi, some feedback about any problem executing the Python Script. The type of error, the line, the column where start the problem, etc. Does someone have an example of this? Please, avoid generic responses or responses not related. Thank's all. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
I made it. The error now says "ModuleNotFoundError" No module named "delphimodule". Do you continue thinking that is better this conversation that try the code I added? Demo on the fly.zip -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
All the demos are about complex examples. Sharing Objects and complex things. Only applicable to try to demonstrate that the person doing it is more intelligent than the rest of the mortals. No examples apply to daily cases like creating integer variables, string variables, float variables, and easy things, like sharing easy methods between python and Delphi. Always complex examples. I think the people that developed these examples are "really very intelligent," but for me, all of them are useless. And the help they give? I wasted my time creating an example. A very easy and straightforward example to show what the problem is. And the attitude of the creators is..... No one tries my code: excuses, excuses, and more excuses. The last, they supposed that I don't watch video tutorials or I don't tried the source code of the demos. I made all of this. But the authors try to exacerbate me. I'm sure. The solution remains here. Tryin the added code and see that the components don't work when you create it on the fly. It is easy. But it is more convenient to have this type of thread where the creators finally stay over the poor users. Is this a serious component set? -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
I've previously done it. But the components continue without work. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
Really doesn't work. There is only a game to pass the time. The things it do does not have sense. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
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. I see these components are still very, very, very, very green. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
Can you please download the included example and try to run it? I beg. Is not a failure of my code. It is a failure of the behavior of the components. If you try it and I'm not in the truth. I will recognize that the components are working well. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
Why do they work when I use visual components? Why can't I use functions and variables created in the __main__ module? What is the matter? Why do I need to create different scripts if I create the components visually than if I create them on the fly? All of this is absurd, true? I've read all the demos and a lot of demos on the web. Of course. I'm going to try this, but this doesn't solve the fact of the different behavior with visual and no visual form of creating the components. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
Yes, but that is where I want to declare the functions and the variables. I've seen a lot of examples that do this. I don't want to include my members in another module. Anyway, with the version of the visual component works very well with the __main__ module. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
I've removed it. All continue in the same form. Do not know the function ComponentCount nor the variable QUANTITY. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
I just changed ExecStrings(Memo1.Lines) to EvalStrings(Memo1.Lines) and... Now it says directly, syntax error on the first line, do not know the meaning of "import sys" -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
This is the form in which I execute the code: FPyEngine.CheckError(); FPyEngine.ExecStrings(Memo1.Lines); And is curious because CheckError() does not report any problem, but ExecStrings says that the functions or variables inserted don't exist. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
This is not the solution to all the problems. This is the more accurate form of doing it. Don't work!!!!! var p :PPyObject; begin FOutput := TStringList.Create; FPythonIO := TPythonInputOutput.Create(Self); FPythonIO.UnicodeIO := True; FPythonIO.RawOutput := False; FPythonIO.OnSendUniData := OnSendUniData; FPyEngine := TPythonEngine.Create(nil); FPyEngine.AutoLoad := False; FPyEngine.DllName := 'python311.dll'; FPyEngine.DllPath := 'C:\Views\senCille\bin\Win64\Python'; FPyEngine.APIVersion := 1013; FPyEngine.RegVersion := '3.11'; FPyEngine.UseLastKnownVersion := False; FPyEngine.OnBeforeLoad := PyEngineBeforeLoad; FPyEngine.InitScript.Add('import sys' ); FPyEngine.InitScript.Add('print ("Python Dll: ", sys.version)'); FPyEngine.InitScript.Add('print (sys.copyright)' ); FPyEngine.InitScript.Add('print' ); FPyEngine.IO := FPythonIO; FPyModule := TPythonModule.Create(nil); FPyModule.Engine := FPyEngine; FPyModule.Name := '__main__'; FPyModule.OnInitialization := PyModuleInitialization; FPyEngine.LoadDll; FPyModule.Initialize; p := FPyEngine.PyLong_FromLong(1); FPyModule.SetVar('QUANTITY', p); FPyEngine.Py_DecRef(p); +++++++ I can't load DLL after PyModule creation or link because I get an error calling Initialize; The script admits the declaration of variables or functions but doesn't recognize either when I run the script. I'm sure it is a problem with the components. I'm investigating it. It probably is creating the variables and the modules in a missing module or something like this. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
Ok. The version with Visual components works with this order of lines: ... {$IFDEF VISUAL_COMPONENTS} PyEngine.IO := FPythonIO; PyEngine.LoadDll; p := PyEngine.PyLong_FromLong(1); PyModule.SetVar('QUANTITY', p); PyEngine.Py_DecRef(p); {$ELSE} ... I'm still fighting with the version of non-visual components. If you want try it, I'm going to thank you. -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
I'm creating TPythonInputOutput on the fly, with visual components. procedure TForm1.FormCreate(Sender: TObject); var p :PPyObject; begin FOutput := TStringList.Create; FPythonIO := TPythonInputOutput.Create(Self); FPythonIO.UnicodeIO := True; FPythonIO.RawOutput := False; FPythonIO.OnSendUniData := OnSendUniData; {$IFDEF VISUAL_COMPONENTS} PyEngine.LoadDll; p := PyEngine.PyLong_FromLong(1); PyModule.SetVar('QUANTITY', p); PyEngine.Py_DecRef(p); PyEngine.IO := FPythonIO; {$ELSE} With the next code in OnSendUniData EventHandler: FOutput.Add(PChar(Data)); And this code in the Button Execute On Click Event Handler: PyEngine.CheckError(); PyEngine.ExecStrings(Memo1.Lines); if FOutput.Count > 0 then begin Memo2.Lines.Assign(FOutput); end; And I always get FOutput.Count = 0. It seems the ExecStrings(Memo1.Lines) don't work well with on the fly created TPythonInputOutput component. I Include the complete code. Demo on Fly.zip -
Getting feedback from the execution. As exceptions or in another kind of management.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
Unfortunately, this solution doesn't work well when you don't use visual components. I need to recover the error messages in a TStringList instance and if there are not empty, translate them to the user, probably in a log file. The first thing is to create the TMemo programmatically without a visual parent, but this doesn't work in the current version of VCL. TMemo visual component needs a Parent to allow add strings in his Lines (TStringList) property, raising an exception if you make this without the Parent assigned. https://quality.embarcadero.com/browse/RSP-40383 I will try to solve this without this visual component. -
tpythondelphivar Creation of TPythonDelphiVar on-the-fly don't works as expected.
Juan C.Cilleruelo replied to Juan C.Cilleruelo's topic in Python4Delphi
The same problem with the class TPythonModule. If I create in visual form, including it on a form, it works well. If I create it on the fly, the next statements FPythonModule.AddDelphiMethod('ComponentCount', ComponentCount, 'ComponentCount'); FPythonModule.AddDelphiMethod('GetPRICE' , GetPRICE , 'GetPRICE' ); run, but when I try to use ComponentCount in my Python Script, does not exist. what's happening?