I tried to use current http://code.google.com/p/python4delphi with
Lazarus. Did somebody use P4D successfully with recent Lazarus?
Patches? I face a few problems.
My aim is to test/use Lazarus+Python as efficient platform
independent and free dev environment. As an alternative to the fat
and baggy wxPython GUI system. Laz, with very small EXE footprint
size and better RAD and tough speed - but just for rather naked
GUI wiring (and few speedy loops - alt: Cython), while doing the
actual app, data, algo, object, file, interface ... work and all,
in Python. Python can also use reversely use Delphi objects/funcs
quite simply. Laz claims to be mature, and the first impression is
good, just re-compilation a little slower than Delphi.
With Delphi I used this P4D method once in a smaller app some time
ago - initially only wanting to re-use some Python modules and
then found me shifting more and more all the data/algo work to
Python. I felt a ">3x" coding speed up and much better
readability, object orientation, overview, interfaces,
flexibility, dynamics/introspection, debugging, testing etc. While
GUI wiring was a lot tighter in D, than wx/wxGlade etc.
P4D worked principally with Lazarus, but only after a few a
adaptations. Mainly setting DELPHI_4..7_OR_HIGHER. see the little
patch in attachment. Is nobody using?
(After re-building Lazarus IDE for Visual Python Components it
Crashes on usage of non-crucial TPythonGUIInputOutput, and the
rebuilt Laz IDE here becomes at all somewhat instable!? But I
stepped back and use the P4D-units/objects just manually, anyway
only a few things to set up and wire...)
Yet when using the crucial VarPyth unit, upon basic things like
pymod := VarPyth.Import('pymod') => EVariantError "Method
TCustomVariantType.VarDataClear not yet supported"
VarPyth variants would allow to walk seamlessly and comfortably
into the Python object tree with the '.' operator like
pymod.myobj.myattr.x(7).y := z; ...
And without that option, much of the P4D charm disappears.
In VarPyth.pas there are many $IFDEF FPC's , but it doesn't seem
to work at all so far!?.
What about this problem, and what could be a workaround?
http://code.google.com/p/python4delphi/source/browse/trunk/PythonForDelphi/Components/Sources/Core/VarPyth.pas
### from variants.pp #########
procedure TCustomVariantType.VarDataClear(var Dest: TVarData);
begin
NotSupported('TCustomVariantType.VarDataClear');
end;
...
#########################
Robert
diff -u Sources/Core/_orig\Definition.Inc Sources/Core\Definition.Inc
--- Sources/Core/_orig\Definition.Inc Fri May 29 16:00:37 2009
+++ Sources/Core\Definition.Inc Fri May 29 16:52:23 2009
@@ -33,7 +33,7 @@
//{$DEFINE PYTHON23}
//{$DEFINE PYTHON24}
//{$DEFINE PYTHON25}
-//{$DEFINE PYTHON26}
+{$DEFINE PYTHON26}
//{$DEFINE PYTHON30}
//{$DEFINE PYTHON31}
@@ -142,6 +142,13 @@
{$DEFINE DELPHI2007_OR_HIGHER}
{$ENDIF}
{$ENDIF}
+{$IFDEF FPC}
+ {$DEFINE DELPHI4_OR_HIGHER}
+ {$DEFINE DELPHI5_OR_HIGHER}
+ {$DEFINE DELPHI6_OR_HIGHER}
+ {$DEFINE DELPHI7_OR_HIGHER}
+{$ENDIF}
+
/////////////////////////////////////////////////////////////////////////////
diff -u Sources/Core/_orig\PythonD6Decs.pas Sources/Core\PythonD6Decs.pas
--- Sources/Core/_orig\PythonD6Decs.pas Fri May 29 16:59:23 2009
+++ Sources/Core\PythonD6Decs.pas Fri May 29 17:04:36 2009
@@ -949,7 +949,7 @@
result:= 1;
if(fLabel=nil) then exit;
result:= 0;
- fLabel.Caption:= PyObjectAsVariant(Value);
+ fLabel.Caption:= String(PyObjectAsVariant(Value));
end; end;
function TPyLabel.DoSetLayout(Value: PPyObject; Context: Pointer): integer;
@@ -966,7 +966,7 @@
result:= 1;
if(fLabel=nil) then exit;
result:= 0;
- fLabel.Transparent:= PyObjectAsVariant(Value);
+ fLabel.Transparent:= Boolean(PyObjectAsVariant(Value));
end; end;
function TPyLabel.DoSetWordWrap(Value: PPyObject;
@@ -1012,7 +1012,7 @@
result:= 1;
if(fForm=nil) then exit;
result:= 0;
- fForm.Caption:= PyObjectAsVariant(Value);
+ fForm.Caption:= String(PyObjectAsVariant(Value));
end; end;
class procedure TPyForm.RegisterGetSets(PythonType: TPythonType);
diff -u Sources/Core/_orig\TinyWideStrings.pas Sources/Core\TinyWideStrings.pas
--- Sources/Core/_orig\TinyWideStrings.pas Fri May 29 16:00:37 2009
+++ Sources/Core\TinyWideStrings.pas Fri May 29 19:57:09 2009
@@ -66,10 +66,11 @@
procedure TWideStringList.Error(const Msg: WideString; Data: Integer);
function ReturnAddr: Pointer;
+ {$IFDEF FPC} begin {$ENDIF}
asm
MOV EAX,[EBP+4]
end;
-
+ {$IFDEF FPC} end; {$ENDIF}
begin
raise EStringListError.CreateFmt(Msg, [Data]) at ReturnAddr;
end;
diff -ur _orig\p4dlaz.lpk .\p4dlaz.lpk
--- _orig\p4dlaz.lpk Wed May 25 20:02:44 2005
+++ .\p4dlaz.lpk Fri May 29 16:49:58 2009
@@ -1,53 +1,51 @@
<?xml version="1.0"?>
<CONFIG>
- <Package Version="2">
+ <Package Version="3">
<PathDelim Value="\"/>
<Name Value="P4DLaz"/>
<CompilerOptions>
- <Version Value="5"/>
+ <Version Value="8"/>
<PathDelim Value="\"/>
<SearchPaths>
- <OtherUnitFiles Value="$(PackageDir)\"/>
- <UnitOutputDirectory Value="C:\P4D\temp"/>
+ <OtherUnitFiles Value="$(PackageDir)\;$(PackageDir)\Sources\Core\"/>
+ <UnitOutputDirectory Value="C:\temp\P4D"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
- <DelphiCompat Value="True"/>
+ <SyntaxMode Value="Delphi"/>
+ <CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
- <CodeGeneration>
- <Generate Value="Faster"/>
- </CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="6">
<Item1>
- <Filename Value="PythonEngine.pas"/>
+ <Filename Value="Sources\Core\PythonEngine.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="PythonEngine"/>
</Item1>
<Item2>
- <Filename Value="PythonGUIInputOutput.pas"/>
+ <Filename Value="Sources\Core\PythonGUIInputOutput.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="PythonGUIInputOutput"/>
</Item2>
<Item3>
- <Filename Value="PythonAction.pas"/>
+ <Filename Value="Sources\Core\PythonAction.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="PythonAction"/>
</Item3>
<Item4>
- <Filename Value="MethodCallBack.pas"/>
+ <Filename Value="Sources\Core\MethodCallBack.pas"/>
<UnitName Value="MethodCallBack"/>
</Item4>
<Item5>
- <Filename Value="VarPyth.pas"/>
+ <Filename Value="Sources\Core\VarPyth.pas"/>
<UnitName Value="VarPyth"/>
</Item5>
<Item6>
- <Filename Value="PythonD6Decs.pas"/>
+ <Filename Value="Sources\Core\PythonD6Decs.pas"/>
<UnitName Value="PythonD6Decs"/>
</Item6>
</Files>
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus