Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 12:57 AM
Tom
Guest
 
Posts: n/a
Default How to call a function in embeded python code in delphi?

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!!








 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles