freelanceprogrammers.org Forum Index » Delphi

Most simple technique for creating a Callback function (Pyth


View user's profile Post To page top
kxroberto Posted: Thu Dec 21, 2006 2:46 pm


Joined: 21 Dec 2006

Posts: 8
Most simple technique for creating a Callback function (Pyth
The demos 5 ff of P4D seem to be overkill for my purpose and I don`t
want/like a visual clickering a TPythonModule Component around
somewhere on a special form but organize some callback functions
ad-hoc and easy inside a decent normal Pascal Unit.

I just want to have e.g. a Delphi Function/Method like

//Delphi module or class function:
function cbProgress(v:double;s:string):integer;
begin
...
end;

//call into Python:
dcore:=Import(`dcore`);
dcore.f( 100, CALLBACK_MAKER(cbProgress) )
dcore.f( 100, CALLBACK_MAKER2(obj.cbProgress) )
...


and in Python doing the callbacks:

#dcore.py:
def f(n, cb):
for i in range(n):
if cb( 100.0*i/n,`test`)!=0:
break
do_something(i)



Think this is a very common pattern of usage.
What is the most easy and readable technique for realizing
CALLBACK_MAKER (for common pascal function layouts) ?
Or is it unavoidable to create a TPythonModule w. AddMethod and all
the args/PPyObject fiddling things for each use case? In that case,
how can I use TPythonModule/AddMethod ad hoc/dynamically without the
visual clickering?


Robert
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
English Courses in England - reservation calendar script
Land Surveying -Stonex instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help