Demo03

Page history last edited by PBworks 3 yrs ago

Defining Python/Delphi vars (simple case): (Kylix ready)

 

Warning ! If you access the Python/Delphi vars with

the variant interface, you'll have to use simple types

like integers, floats or strings.

If you want to use any Python object type, don't use

variants, but use the Extended interface OnExtGetData, OnExtSetData

and the ValueObject property. But in this case, be careful with the

reference counting ! Study carefully the Demo4 example.

 

  1. Drop a TPythonDelphiVar
  2. Connect its Engine attribute to PythonEngine1
  3. Change the name of the variable in the VarName attribute and set it to "test" .
  4. Drop a Button and call it "Show var content"
  5. Double-click on it, and add:

ShowMessage( 'Value = ' + PythonDelphiVar1.ValueAsString );

  1. Run the application, and type in the source window:

varname.Value = 10

print varname, varname.Value

  1. Click on the Execute button
  2. Click on the "Show var content button"

 

So, you can read/write the variable's content in both Python and Delphi !

Comments (0)

You don't have permission to comment on this page.