delphi 7 python 2.3 win98 Python for Delphi V3.25
In Delphi:
1 Create a new Form ;
2 Drop a TMemo(Memo1) to contain python code;
3 Drop a TPythonInputOutput (PythonInputOutput1) ;
4 Drop a TPythonEngine (PythonEngine1) ;
5 Drag a PythonDelphiVar component and name it bx. Set the VarName property to the same as its name;
6 Connect the attribute IO of the TPythonEngine to the TPythonInputOutput;
7 Drop a TButton (Button1) ;
8 Write python code in the Memo1 (set Memo1's property of lines):
def ax(m,n): y=10 bx.value=y+m+n ...
Now, As click Button1, how to call the funtion ax passing the arguments(such as m=33 and n=25), and get bx.ValueAsString ;
Delphi Code:
---------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PythonEngine, StdCtrls;
type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; PythonEngine1: TPythonEngine; bx: TPythonDelphiVar; PythonInputOutput1: TPythonInputOutput; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
/////////////////////////////////////////////////
// //
// How to call the funtion ax passing the //
// arguments(such as m=33 and n=25), and //
// get bx.ValueAsString ?? //
// // /////////////////////////////////////////////////
showmessage( bx.ValueAsString );
end;
end.
-------------------------------
Thank you very much!!
-- http://mail.python.org/mailman/listinfo/python-list