ShowMessage( ‘args of foo: ‘+PyObjectAsString(args) ) Procedure TForm1.PythonModule1Initialization(Sender: TObject) Īns here’s the example of functions defined for the module spam in this context the function spam_foo with forms caption return:įunction TForm1.spam_foo(pself, args : PPyObject): PPyObject cdecl What would be if we use in a internal Python-script some Delphi-methods like in the above script methods of the import module spam? First we had to initialize the module spam, we just need to add our new methods: But the eval-uation of an expression works only for arithmetic expressions and not for instructions ! The use of variables and functions is of course possible but constructs like for, def, catch, class, print, import… are not implemented, you use for this ExecStrings() and not EvalStrings(). You do also have the evaluation of an expression. 'print ("Current value of var test is: ", test)' So in a more complicated script we do have a same memo-control but simply with more lines: Object PythonGUIInputOutput1: TpythonGUIInputOutput You should see in the Output as Memo2 window: 5Īs we can see the memo-control manifests the Python-script as input in memo1 and output in memo2: PythonEngine1.ExecStrings(Memo1.Lines).Drop a TButton and call it “Execute script”.Connect the attribute Output of TPythonGUIInputOutput to.Connect the attribute IO of the TPythonEngine to.Drop a TPythonGUIInputOutput for displaying Python’s results.For the next section I want to show more practical implementations. In the last Article we have seen that P4D is a set of free components that wrap up the Python DLL into Delphi and Lazarus (FPC). MaXbox Starter86_3 – Code with Python4Delphiīe yourself Everyone else is already taken. MaXbox Starter86_2 – Code with Python4Delphi
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |