473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to call a function in embeded python code in delphi?

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


Jul 18 '05 #1
0 1565

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PythonMan | last post by:
Any Software can change Python source code to Delphi ? thx --
9
by: Edilmar | last post by:
Hi, First of all, I'm new in Python... I have worked with manu langs and IDEs, like Delphi, VB, JBuilder, Eclipse, Borland C++, Perl, etc... Then, today I think IDEs like Delphi have a...
13
by: ulysses | last post by:
Hi,all I use wxPython make a bittorrent client. I find wxPython very slow and use many many memory. When app start, it need 19MB memory. I only use common GUI components. Python is a really...
0
by: Ilariu Raducan | last post by:
Hi All, In embeded python, is it possible to add functions to a module after initialization with Py_InitModule? I don't know the function names and implementation of them at the compile time. At...
81
by: julio | last post by:
Sorry but there is no another way, c# .net and mono are going to rip python, not because python is a bad lenguage, but because is to darn old and it refuses to innovate things, to fix wrong things,...
0
by: azerty | last post by:
Hello I develop an application which must call a WebService on a server (develop with ASP.NET framework) If I call this application from XP client station, no problem occurs BUT if i call...
18
by: spiffo | last post by:
The Main Issue in a nutshell I am a corporate developer, working for a single company. Got a new project coming up and wondering if I should stay with Python for this new, fairly large project,...
3
by: simon | last post by:
Hi, I know this is not the most appropriate newsgroup for this question, but has many members and I hope someone can help me. I have visual studio 2005 beta2. I would like to use embeded...
23
by: gord | last post by:
As a complete novice in the study of Python, I am asking myself where this language is superior or better suited than others. For example, all I see in the tutorials are lots of examples of list...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.