diff --git a/.gitignore b/.gitignore index 10ae397c..a75051df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,44 +1,64 @@ +PythonForDelphi/Components/FPC_Units/ +PythonForDelphi/Components/Sources/Core/backup/ + # Compiled source # ################### -*.dcu +* +.dcu + *.obj + *.exe + *.bpl + *.bpi + *.dcp + *.rsm + *.stat + *.map + # Generated source # ################### + *.hpp + # Backup files # ################### + *.~* -# IDE Files # + +#IDE Files # ################### -*.dproj.local +* +*.dproj +*.local + *.groupproj.local + *.identcache + *.dsk + *.tvsconfig + *.otares + *.drc + *.rc + *.res -*.local -# Output Folders # -################### -/Win32 -/Win64 -/OSX32 -/__history -*.bak -*.Patch -VirtualTreeView.zip -*.#00 -*.pch +*.local +*.pyd +*.res +*.lrs +*.lpi \ No newline at end of file diff --git a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas index cae49ef4..18283dfb 100644 --- a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas +++ b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas @@ -90,7 +90,9 @@ interface {$ELSE} TinyWideStrings, {$ENDIF} - MethodCallBack; + MethodCallBack, + Dialogs, + Forms ; //####################################################### //## ## @@ -3362,10 +3364,10 @@ function TDynamicDll.GetDllPath : String; {$ENDIF} begin Result := DllPath; - {$IFDEF MSWINDOWS} if DLLPath = '' then begin - IsPythonVersionRegistered(RegVersion, Result, AllUserInstall); + DllPath:= ExtractFilePath(Application.ExeName); + //IsPythonVersionRegistered(RegVersion, Result, AllUserInstall); end; {$ENDIF} @@ -3386,7 +3388,7 @@ procedure TDynamicDll.OpenDll(const aDllName : String); FDLLHandle := 0; DoOpenDll(aDllName); - + //showmessage(format('path: %s name: %s',[dllPath,DllName])); if not IsHandleValid then begin {$IFDEF MSWINDOWS} s := Format('Error %d: Could not open Dll "%s"',[GetLastError, DllName]); @@ -5887,7 +5889,7 @@ function TPythonEngine.VariantAsPyObject( const V : Variant ) : PPyObject; // detect if the variant supports this special property if Assigned(Disp) and (Disp.GetIDsOfNames(GUID_NULL, @wStr, 1, 0, @DispID) = S_OK) then begin - myInt := DeRefV.__asPPyObject__; //Returns the address to PPyObject as integer. (See impl. in PythonAtom.pas) + myInt := intptr(DeRefV.__asPPyObject__); //Returns the address to PPyObject as integer. (See impl. in PythonAtom.pas) Result := PPyObject(myInt); Py_XIncRef(Result); end diff --git a/PythonForDelphi/Components/Sources/Core/VarPyth.pas b/PythonForDelphi/Components/Sources/Core/VarPyth.pas index 89137bd6..2b9b269f 100644 --- a/PythonForDelphi/Components/Sources/Core/VarPyth.pas +++ b/PythonForDelphi/Components/Sources/Core/VarPyth.pas @@ -1348,7 +1348,7 @@ function TPythonVariantType.GetPropertyWithArg(var Dest: TVarData; // So: myList[0] won't work, but myObj.MyList[0] will!!! if PySequence_Check(_prop) <> 0 then begin - _result := PySequence_GetItem(_prop, Variant(AArg)); + _result := PySequence_GetItem(_prop, IntPtr(Variant(AArg))); CheckError; end; // of if end; // of if @@ -1438,13 +1438,13 @@ function TPythonVariantType.EvalPython(const V: TVarData; if not Assigned(_value) then raise Exception.Create(SCantConvertValueToPythonObject); if PyList_Check(AObject) then - _result := PyList_SetItem( AObject, Variant(AKey), _value ) + _result := PyList_SetItem( AObject, IntPtr(Variant(AKey)), _value ) else if PyTuple_Check(AObject) then - _result := PyTuple_SetItem( AObject, Variant(AKey), _value ) + _result := PyTuple_SetItem( AObject, IntPtr(Variant(AKey)), _value ) else try if PySequence_Check(AObject) <> 0 then - _result := PySequence_SetItem(AObject, Variant(AKey), _value) + _result := PySequence_SetItem(AObject, IntPtr(Variant(AKey)), _value) else _result := PyObject_SetItem( AObject, _key, _value ); finally diff --git a/PythonForDelphi/Demos/FPC/Demo01/project1.lpi b/PythonForDelphi/Demos/FPC/Demo01/project1.lpi index bfc0f0d8..bb4b50ee 100644 --- a/PythonForDelphi/Demos/FPC/Demo01/project1.lpi +++ b/PythonForDelphi/Demos/FPC/Demo01/project1.lpi @@ -1,21 +1,87 @@ - + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -42,17 +108,16 @@ - + - - + @@ -61,24 +126,19 @@ - - - - - - + @@ -87,11 +147,9 @@ - - - - - + + + @@ -99,9 +157,7 @@ - - - + @@ -109,20 +165,17 @@ - - - - - + + + + - - @@ -130,7 +183,6 @@ - @@ -146,12 +198,11 @@ - - + @@ -168,9 +219,6 @@ - - - diff --git a/PythonForDelphi/Demos/FPC/Demo01/project1.res b/PythonForDelphi/Demos/FPC/Demo01/project1.res index 7c6cf3e4..03adc0a9 100644 Binary files a/PythonForDelphi/Demos/FPC/Demo01/project1.res and b/PythonForDelphi/Demos/FPC/Demo01/project1.res differ diff --git a/PythonForDelphi/Demos/FPC/Demo01/unit1.lfm b/PythonForDelphi/Demos/FPC/Demo01/unit1.lfm index c5f75d31..c37b036c 100644 --- a/PythonForDelphi/Demos/FPC/Demo01/unit1.lfm +++ b/PythonForDelphi/Demos/FPC/Demo01/unit1.lfm @@ -3,10 +3,13 @@ object Form1: TForm1 Height = 391 Top = 175 Width = 547 + ActiveControl = Memo1 Caption = 'Form1' ClientHeight = 391 ClientWidth = 547 - LCLVersion = '0.9.30.2' + DesignTimePPI = 134 + LCLVersion = '1.7' + Visible = False object Panel1: TPanel Left = 0 Height = 391 @@ -15,6 +18,7 @@ object Form1: TForm1 Align = alClient ClientHeight = 391 ClientWidth = 547 + ParentFont = False TabOrder = 0 object Memo1: TMemo Left = 1 @@ -22,6 +26,7 @@ object Form1: TForm1 Top = 1 Width = 545 Align = alTop + ParentFont = False TabOrder = 0 end object PairSplitter1: TPairSplitter @@ -53,8 +58,9 @@ object Form1: TForm1 Width = 545 Align = alClient Lines.Strings = ( - 'print 2+2' + 'print(2+2)' ) + ParentFont = False TabOrder = 2 end object Panel2: TPanel @@ -65,6 +71,7 @@ object Form1: TForm1 Align = alBottom ClientHeight = 46 ClientWidth = 545 + ParentFont = False TabOrder = 3 object Button1: TButton Left = 223 @@ -73,21 +80,23 @@ object Form1: TForm1 Width = 75 Caption = 'Execute' OnClick = Button1Click + ParentFont = False TabOrder = 0 end end end object PythonEngine1: TPythonEngine IO = PythonGUIInputOutput1 - left = 96 - top = 48 + PyFlags = [pfIgnoreEnvironmentFlag] + Left = 96 + Top = 48 end object PythonGUIInputOutput1: TPythonGUIInputOutput DelayWrites = True UnicodeIO = False RawOutput = False Output = Memo1 - left = 338 - top = 48 + Left = 338 + Top = 48 end end diff --git a/PythonForDelphi/Demos/FPC/Demo01/unit1.lrs b/PythonForDelphi/Demos/FPC/Demo01/unit1.lrs index 4dcd8024..014849de 100644 --- a/PythonForDelphi/Demos/FPC/Demo01/unit1.lrs +++ b/PythonForDelphi/Demos/FPC/Demo01/unit1.lrs @@ -2,24 +2,27 @@ LazarusResources.Add('TForm1','FORMDATA',[ 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'"'#1#6'Height'#3#135#1#3'Top'#3#175#0#5'W' - +'idth'#3'#'#2#7'Caption'#6#5'Form1'#12'ClientHeight'#3#135#1#11'ClientWidth' - +#3'#'#2#10'LCLVersion'#6#8'0.9.30.2'#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Hei' - +'ght'#3#135#1#3'Top'#2#0#5'Width'#3'#'#2#5'Align'#7#8'alClient'#12'ClientHei' - +'ght'#3#135#1#11'ClientWidth'#3'#'#2#8'TabOrder'#2#0#0#5'TMemo'#5'Memo1'#4'L' - +'eft'#2#1#6'Height'#3#183#0#3'Top'#2#1#5'Width'#3'!'#2#5'Align'#7#5'alTop'#8 - +'TabOrder'#2#0#0#0#13'TPairSplitter'#13'PairSplitter1'#4'Left'#2#1#6'Height' - +#2#8#3'Top'#3#184#0#5'Width'#3'!'#2#5'Align'#7#5'alTop'#8'Position'#2'-'#0#17 - +'TPairSplitterSide'#17'PairSplitterSide1'#6'Cursor'#7#7'crArrow'#4'Left'#2#0 - +#6'Height'#2#8#3'Top'#2#0#5'Width'#2'-'#0#0#17'TPairSplitterSide'#17'PairSpl' - +'itterSide2'#6'Cursor'#7#7'crArrow'#4'Left'#2'2'#6'Height'#2#8#3'Top'#2#0#5 - +'Width'#3#239#1#0#0#0#5'TMemo'#5'Memo2'#4'Left'#2#1#6'Height'#3#152#0#3'Top' - +#3#192#0#5'Width'#3'!'#2#5'Align'#7#8'alClient'#13'Lines.Strings'#1#6#9'prin' - +'t 2+2'#0#8'TabOrder'#2#2#0#0#6'TPanel'#6'Panel2'#4'Left'#2#1#6'Height'#2'.' - +#3'Top'#3'X'#1#5'Width'#3'!'#2#5'Align'#7#8'alBottom'#12'ClientHeight'#2'.' - +#11'ClientWidth'#3'!'#2#8'TabOrder'#2#3#0#7'TButton'#7'Button1'#4'Left'#3#223 - +#0#6'Height'#2#25#3'Top'#2#8#5'Width'#2'K'#7'Caption'#6#7'Execute'#7'OnClick' - +#7#12'Button1Click'#8'TabOrder'#2#0#0#0#0#0#13'TPythonEngine'#13'PythonEngin' - +'e1'#2'IO'#7#21'PythonGUIInputOutput1'#4'left'#2'`'#3'top'#2'0'#0#0#21'TPyth' - +'onGUIInputOutput'#21'PythonGUIInputOutput1'#11'DelayWrites'#9#9'UnicodeIO'#8 - +#9'RawOutput'#8#6'Output'#7#5'Memo1'#4'left'#3'R'#1#3'top'#2'0'#0#0#0 + +'idth'#3'#'#2#13'ActiveControl'#7#5'Memo1'#7'Caption'#6#5'Form1'#12'ClientHe' + +'ight'#3#135#1#11'ClientWidth'#3'#'#2#13'DesignTimePPI'#3#134#0#10'LCLVersio' + +'n'#6#3'1.7'#7'Visible'#8#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#3#135#1 + +#3'Top'#2#0#5'Width'#3'#'#2#5'Align'#7#8'alClient'#12'ClientHeight'#3#135#1 + +#11'ClientWidth'#3'#'#2#10'ParentFont'#8#8'TabOrder'#2#0#0#5'TMemo'#5'Memo1' + +#4'Left'#2#1#6'Height'#3#183#0#3'Top'#2#1#5'Width'#3'!'#2#5'Align'#7#5'alTop' + +#10'ParentFont'#8#8'TabOrder'#2#0#0#0#13'TPairSplitter'#13'PairSplitter1'#4 + +'Left'#2#1#6'Height'#2#8#3'Top'#3#184#0#5'Width'#3'!'#2#5'Align'#7#5'alTop'#8 + +'Position'#2'-'#0#17'TPairSplitterSide'#17'PairSplitterSide1'#6'Cursor'#7#7 + +'crArrow'#4'Left'#2#0#6'Height'#2#8#3'Top'#2#0#5'Width'#2'-'#0#0#17'TPairSpl' + +'itterSide'#17'PairSplitterSide2'#6'Cursor'#7#7'crArrow'#4'Left'#2'2'#6'Heig' + +'ht'#2#8#3'Top'#2#0#5'Width'#3#239#1#0#0#0#5'TMemo'#5'Memo2'#4'Left'#2#1#6'H' + +'eight'#3#152#0#3'Top'#3#192#0#5'Width'#3'!'#2#5'Align'#7#8'alClient'#13'Lin' + +'es.Strings'#1#6#10'print(2+2)'#0#10'ParentFont'#8#8'TabOrder'#2#2#0#0#6'TPa' + +'nel'#6'Panel2'#4'Left'#2#1#6'Height'#2'.'#3'Top'#3'X'#1#5'Width'#3'!'#2#5'A' + +'lign'#7#8'alBottom'#12'ClientHeight'#2'.'#11'ClientWidth'#3'!'#2#10'ParentF' + +'ont'#8#8'TabOrder'#2#3#0#7'TButton'#7'Button1'#4'Left'#3#223#0#6'Height'#2 + +#25#3'Top'#2#8#5'Width'#2'K'#7'Caption'#6#7'Execute'#7'OnClick'#7#12'Button1' + +'Click'#10'ParentFont'#8#8'TabOrder'#2#0#0#0#0#0#13'TPythonEngine'#13'Python' + +'Engine1'#2'IO'#7#21'PythonGUIInputOutput1'#7'PyFlags'#11#23'pfIgnoreEnviron' + +'mentFlag'#0#4'Left'#2'`'#3'Top'#2'0'#0#0#21'TPythonGUIInputOutput'#21'Pytho' + +'nGUIInputOutput1'#11'DelayWrites'#9#9'UnicodeIO'#8#9'RawOutput'#8#6'Output' + +#7#5'Memo1'#4'Left'#3'R'#1#3'Top'#2'0'#0#0#0 ]); diff --git a/PythonForDelphi/Demos/FPC/Demo06/Project1.lpi b/PythonForDelphi/Demos/FPC/Demo06/Project1.lpi index 21a8b55f..8c7aa3fd 100644 --- a/PythonForDelphi/Demos/FPC/Demo06/Project1.lpi +++ b/PythonForDelphi/Demos/FPC/Demo06/Project1.lpi @@ -12,8 +12,76 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -35,13 +103,14 @@ - + - - - + + + + @@ -51,24 +120,25 @@ - - - + + + - + - - - - + + + + + @@ -77,7 +147,7 @@ - + @@ -85,15 +155,15 @@ - + - - - + + + @@ -101,18 +171,169 @@ - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -134,15 +355,6 @@ - - - - - - - - - diff --git a/PythonForDelphi/Demos/FPC/Demo06/Unit1.lfm b/PythonForDelphi/Demos/FPC/Demo06/Unit1.lfm index c02dca2b..f106d124 100644 --- a/PythonForDelphi/Demos/FPC/Demo06/Unit1.lfm +++ b/PythonForDelphi/Demos/FPC/Demo06/Unit1.lfm @@ -8,10 +8,10 @@ object Form1: TForm1 ClientHeight = 500 ClientWidth = 800 Color = clBtnFace + DesignTimePPI = 134 Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' - LCLVersion = '1.8.0.6' Visible = False object Splitter1: TSplitter Cursor = crVSplit @@ -31,17 +31,18 @@ object Form1: TForm1 Lines.Strings = ( 'import sys' 'import spam' - 'print spam.foo(''hello world'', 1)' + 'print(spam.foo(''hello world'', 1))' 'p = spam.CreatePoint( 10, 25 )' - 'print "Point:", p' + 'print( "Point:", p)' 'p.x = 58' - 'print p.x, p' + 'print( p.x, p)' 'p.OffsetBy( 5, 5 )' - 'print p' - 'print "Current value of var test is: ", test' + 'print(p)' + 'print("Current value of var test is: ", test)' 'test.Value = "New value set by Python"' - 'print "getdouble: ", spam.getdouble()' + 'print("getdouble: ", spam.getdouble())' ) + ParentFont = False ScrollBars = ssVertical TabOrder = 1 end @@ -54,6 +55,7 @@ object Form1: TForm1 BevelOuter = bvNone ClientHeight = 68 ClientWidth = 800 + ParentFont = False TabOrder = 0 object Button1: TButton Left = 40 @@ -62,6 +64,7 @@ object Form1: TForm1 Width = 115 Caption = 'Execute script' OnClick = Button1Click + ParentFont = False TabOrder = 0 end object Button2: TButton @@ -71,6 +74,7 @@ object Form1: TForm1 Width = 91 Caption = 'Load script...' OnClick = Button2Click + ParentFont = False TabOrder = 1 end object Button3: TButton @@ -80,6 +84,7 @@ object Form1: TForm1 Width = 89 Caption = 'Save script...' OnClick = Button3Click + ParentFont = False TabOrder = 2 end object Button4: TButton @@ -89,13 +94,15 @@ object Form1: TForm1 Width = 89 Caption = 'Show var test' OnClick = Button4Click + ParentFont = False TabOrder = 3 end object Edit1: TEdit Left = 500 - Height = 20 + Height = 28 Top = 8 Width = 150 + ParentFont = False TabOrder = 4 end end @@ -108,17 +115,19 @@ object Form1: TForm1 Lines.Strings = ( 'Memo2' ) + ParentFont = False TabOrder = 2 end object PythonEngine1: TPythonEngine InitScript.Strings = ( 'import sys' - 'print "Python Dll: ", sys.version' - 'print sys.copyright' + 'print("Python Dll: ", sys.version)' + 'print(sys.copyright)' 'print' ) IO = PythonGUIInputOutput1 - left = 8 + PyFlags = [pfIgnoreEnvironmentFlag] + Left = 8 end object PythonType1: TPythonType Engine = PythonEngine1 @@ -130,24 +139,24 @@ object Form1: TForm1 Services.Number = [] Services.Sequence = [] Services.Mapping = [] - left = 72 + Left = 72 end object PythonModule1: TPythonModule Engine = PythonEngine1 OnInitialization = PythonModule1Initialization ModuleName = 'spam' Errors = <> - left = 104 + Left = 104 end object OpenDialog1: TOpenDialog DefaultExt = '.*.py' Filter = 'Python files|*.py|Text files|*.txt|All files|*.*' - left = 176 + Left = 176 end object SaveDialog1: TSaveDialog DefaultExt = '.*.py' Filter = 'Python files|*.py|Text files|*.txt|All files|*.*' - left = 208 + Left = 208 end object PythonDelphiVar1: TPythonDelphiVar Engine = PythonEngine1 @@ -156,12 +165,12 @@ object Form1: TForm1 OnGetData = PythonDelphiVar1GetData OnSetData = PythonDelphiVar1SetData OnChange = PythonDelphiVar1Change - left = 136 + Left = 136 end object PythonGUIInputOutput1: TPythonGUIInputOutput UnicodeIO = True RawOutput = False Output = Memo2 - left = 40 + Left = 40 end end diff --git a/PythonForDelphi/Demos/FPC/Demo06/Unit1.pas b/PythonForDelphi/Demos/FPC/Demo06/Unit1.pas index 85b22e63..0ce458a5 100644 --- a/PythonForDelphi/Demos/FPC/Demo06/Unit1.pas +++ b/PythonForDelphi/Demos/FPC/Demo06/Unit1.pas @@ -8,7 +8,7 @@ interface SysUtils, Classes, {$IFDEF MSWINDOWS} Windows, Messages, Graphics, Controls, Forms, Dialogs, - StdCtrls, ComCtrls, ExtCtrls, + StdCtrls, ComCtrls, ExtCtrls, Menus, {$ENDIF} {$IFDEF LINUX} QForms, QDialogs, QStdCtrls, QControls, QExtCtrls, @@ -173,9 +173,10 @@ function PyPoint_getattr(obj : PPyObject; key : PAnsiChar) : PPyObject; cdecl; else begin // Else check for a method - Result := Py_FindMethod( MethodsByName('PythonType1'), obj, key); + Result:=PyObject_GenericGetAttr(obj,PyString_FromString('OffsetBy')); + //Result := Py_FindMethod( MethodsByName('PythonType1'), obj, key); // or we could write, because it's quicker: - // Result := Py_FindMethod( Form1.PythonType1.MethodsData, obj, key); + //Result := Py_FindMethod( Form1.PythonType1.MethodsData, obj, key); if not Assigned(Result) then PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format('Unknown attribute "%s"',[key]))); end; @@ -249,7 +250,7 @@ procedure TForm1.PythonType1Initialization(Sender: TObject); // In the initialization of a new type, we must // define the attributes of this type PyType := TheType; - with PyType do + with PyType do begin tp_basicsize := sizeof(PyPointRec); tp_dealloc := PyPoint_dealloc; @@ -260,7 +261,8 @@ procedure TForm1.PythonType1Initialization(Sender: TObject); end; TheType := PyType; // And then add the methods of the object, if needed - AddMethod( 'OffsetBy', PyPoint_OffsetBy, 'OffsetBy(dx, dy)' ); + AddMethod( 'OffsetBy', PyPoint_OffsetBy , 'OffsetBy(dx, dy)' ); + PythonEngine1.PyType_Ready(TheTypePtr); end; end; diff --git a/PythonForDelphi/Demos/FPC/Demo25/project1.lpi b/PythonForDelphi/Demos/FPC/Demo25/project1.lpi index b90ec537..ee816dc6 100644 --- a/PythonForDelphi/Demos/FPC/Demo25/project1.lpi +++ b/PythonForDelphi/Demos/FPC/Demo25/project1.lpi @@ -1,20 +1,89 @@ - + + - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -36,209 +105,206 @@ - + - - + + - - - - + + + + + - - + - + - + - + - + - + - - - - - - - + + + + + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + @@ -248,25 +314,34 @@ - - - + + + + + + + + + + + + diff --git a/PythonForDelphi/Demos/FPC/Demo25/project1.res b/PythonForDelphi/Demos/FPC/Demo25/project1.res index 708df3c5..877868cb 100644 Binary files a/PythonForDelphi/Demos/FPC/Demo25/project1.res and b/PythonForDelphi/Demos/FPC/Demo25/project1.res differ diff --git a/PythonForDelphi/Demos/FPC/Demo25/unit1.lfm b/PythonForDelphi/Demos/FPC/Demo25/unit1.lfm index 2dae9480..1b683e1a 100644 --- a/PythonForDelphi/Demos/FPC/Demo25/unit1.lfm +++ b/PythonForDelphi/Demos/FPC/Demo25/unit1.lfm @@ -3,11 +3,13 @@ object Form1: TForm1 Height = 522 Top = 100 Width = 795 + ActiveControl = Memo1 Caption = 'Form1' ClientHeight = 522 ClientWidth = 795 + DesignTimePPI = 134 OnCreate = FormCreate - LCLVersion = '0.9.28.2' + Visible = False object Panel1: TPanel Left = 0 Height = 522 @@ -16,6 +18,7 @@ object Form1: TForm1 Align = alClient ClientHeight = 522 ClientWidth = 795 + ParentFont = False TabOrder = 0 object Memo1: TMemo Left = 1 @@ -23,6 +26,7 @@ object Form1: TForm1 Top = 1 Width = 793 Align = alTop + ParentFont = False TabOrder = 0 end object PairSplitter1: TPairSplitter @@ -61,7 +65,7 @@ object Form1: TForm1 ' def __init__(Self, Value=0):' ' Self.Value = Value' ' def __del__(Self):' - ' print "delete", Self' + ' print( "delete", Self)' ' def __add__(self, other):' ' return Foo(self.Value + other.Value)' ' def Inc(Self, AValue = 1):' @@ -85,13 +89,14 @@ object Form1: TForm1 ' return [a, b, c, d]' '' 'f = Foo()' - 'print "Created", f' + 'print( "Created", f)' 'f.Inc()' 'f.Inc(2)' 'b = Bar()' 'b.Inc()' 'b.Inc(2)' ) + ParentFont = False TabOrder = 2 end object Panel2: TPanel @@ -102,6 +107,7 @@ object Form1: TForm1 Align = alBottom ClientHeight = 113 ClientWidth = 793 + ParentFont = False TabOrder = 3 object Button1: TButton Left = 15 @@ -110,6 +116,7 @@ object Form1: TForm1 Width = 75 Caption = 'Execute' OnClick = Button1Click + ParentFont = False TabOrder = 0 end object btnTestIntegers: TButton @@ -119,29 +126,31 @@ object Form1: TForm1 Width = 75 Caption = 'Test Integers' OnClick = btnTestIntegersClick + ParentFont = False TabOrder = 1 end object cbTestIntegers: TCheckBox Left = 122 - Height = 19 + Height = 24 Top = 41 - Width = 66 + Width = 81 Caption = 'Included' + ParentFont = False TabOrder = 2 end end end object PythonEngine1: TPythonEngine IO = PythonGUIInputOutput1 - left = 96 - top = 48 + Left = 96 + Top = 48 end object PythonGUIInputOutput1: TPythonGUIInputOutput DelayWrites = True UnicodeIO = False RawOutput = False Output = Memo1 - left = 338 - top = 48 + Left = 338 + Top = 48 end end diff --git a/PythonForDelphi/Demos/FPC/Demo25/unit1.lrs b/PythonForDelphi/Demos/FPC/Demo25/unit1.lrs index 1ab0eccf..50cd9e40 100644 --- a/PythonForDelphi/Demos/FPC/Demo25/unit1.lrs +++ b/PythonForDelphi/Demos/FPC/Demo25/unit1.lrs @@ -1,40 +1,44 @@ +{ This is an automatically generated lazarus resource file } + LazarusResources.Add('TForm1','FORMDATA',[ 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3't'#1#6'Height'#3#10#2#3'Top'#2'd'#5'Width' - +#3#27#3#7'Caption'#6#5'Form1'#12'ClientHeight'#3#10#2#11'ClientWidth'#3#27#3 - +#8'OnCreate'#7#10'FormCreate'#10'LCLVersion'#6#8'0.9.28.2'#0#6'TPanel'#6'Pan' - +'el1'#4'Left'#2#0#6'Height'#3#10#2#3'Top'#2#0#5'Width'#3#27#3#5'Align'#7#8'a' - +'lClient'#12'ClientHeight'#3#10#2#11'ClientWidth'#3#27#3#8'TabOrder'#2#0#0#5 - +'TMemo'#5'Memo1'#4'Left'#2#1#6'Height'#3#231#0#3'Top'#2#1#5'Width'#3#25#3#5 - +'Align'#7#5'alTop'#8'TabOrder'#2#0#0#0#13'TPairSplitter'#13'PairSplitter1'#4 - +'Left'#2#1#6'Height'#2#8#3'Top'#3#232#0#5'Width'#3#25#3#5'Align'#7#5'alTop'#8 - +'Position'#2'-'#0#17'TPairSplitterSide'#17'PairSplitterSide1'#6'Cursor'#7#7 - +'crArrow'#4'Left'#2#0#6'Height'#2#8#3'Top'#2#0#5'Width'#2'-'#0#0#17'TPairSpl' - +'itterSide'#17'PairSplitterSide2'#6'Cursor'#7#7'crArrow'#4'Left'#2'2'#6'Heig' - +'ht'#2#8#3'Top'#2#0#5'Width'#3#231#2#0#0#0#5'TMemo'#5'Memo2'#4'Left'#2#1#6'H' - +'eight'#3#168#0#3'Top'#3#240#0#5'Width'#3#25#3#5'Align'#7#8'alClient'#13'Lin' - +'es.Strings'#1#6#18'class XYZ(object):'#6#6' pass'#6#0#6#10'class Foo:'#6#30 + +#3#27#3#13'ActiveControl'#7#5'Memo1'#7'Caption'#6#5'Form1'#12'ClientHeight'#3 + +#10#2#11'ClientWidth'#3#27#3#13'DesignTimePPI'#3#134#0#8'OnCreate'#7#10'Form' + +'Create'#7'Visible'#8#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#3#10#2#3'T' + +'op'#2#0#5'Width'#3#27#3#5'Align'#7#8'alClient'#12'ClientHeight'#3#10#2#11'C' + +'lientWidth'#3#27#3#10'ParentFont'#8#8'TabOrder'#2#0#0#5'TMemo'#5'Memo1'#4'L' + +'eft'#2#1#6'Height'#3#231#0#3'Top'#2#1#5'Width'#3#25#3#5'Align'#7#5'alTop'#10 + +'ParentFont'#8#8'TabOrder'#2#0#0#0#13'TPairSplitter'#13'PairSplitter1'#4'Lef' + +'t'#2#1#6'Height'#2#8#3'Top'#3#232#0#5'Width'#3#25#3#5'Align'#7#5'alTop'#8'P' + +'osition'#2'-'#0#17'TPairSplitterSide'#17'PairSplitterSide1'#6'Cursor'#7#7'c' + +'rArrow'#4'Left'#2#0#6'Height'#2#8#3'Top'#2#0#5'Width'#2'-'#0#0#17'TPairSpli' + +'tterSide'#17'PairSplitterSide2'#6'Cursor'#7#7'crArrow'#4'Left'#2'2'#6'Heigh' + +'t'#2#8#3'Top'#2#0#5'Width'#3#231#2#0#0#0#5'TMemo'#5'Memo2'#4'Left'#2#1#6'He' + +'ight'#3#168#0#3'Top'#3#240#0#5'Width'#3#25#3#5'Align'#7#8'alClient'#13'Line' + +'s.Strings'#1#6#18'class XYZ(object):'#6#6' pass'#6#0#6#10'class Foo:'#6#30 +' def __init__(Self, Value=0):'#6#22' Self.Value = Value'#6#20' def __d' - +'el__(Self):'#6#24' print "delete", Self'#6#27' def __add__(self, other)' - +':'#6'( return Foo(self.Value + other.Value)'#6#28' def Inc(Self, AValue' - +' = 1):'#6'$ Self.Value = Self.Value + AValue'#6#20' def GetSelf(Self):' - +#6#15' return Self'#6#21' def GetValue(Self):'#6#21' return Self.Valu' - +'e'#6#28' def SetABC(Self, A, B, C):'#6#14' Self.A = A'#6#14' Self.B ' - +'= B'#6#14' Self.C = C'#6#26' def Add(Self, AFooInst):'#6', Self.Valu' - +'e = Self.Value + AFooInst.Value'#6#15'class Bar(Foo):'#6#28' def Inc(Self,' - +' AValue = 1):'#6'$ Self.Value = Self.Value - AValue'#6#14'def Add(a, b):' - +#6#14' return a + b'#6#25'def MakeList(a, b, c, d):'#6#21' return [a, b, c' - +', d]'#6#0#6#9'f = Foo()'#6#18'print "Created", f'#6#7'f.Inc()'#6#8'f.Inc(2)' - +#6#9'b = Bar()'#6#7'b.Inc()'#6#8'b.Inc(2)'#0#8'TabOrder'#2#2#0#0#6'TPanel'#6 - +'Panel2'#4'Left'#2#1#6'Height'#2'q'#3'Top'#3#152#1#5'Width'#3#25#3#5'Align'#7 - +#8'alBottom'#12'ClientHeight'#2'q'#11'ClientWidth'#3#25#3#8'TabOrder'#2#3#0#7 - +'TButton'#7'Button1'#4'Left'#2#15#6'Height'#2#25#3'Top'#2#8#5'Width'#2'K'#7 - +'Caption'#6#7'Execute'#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#0#0#0#7'T' - +'Button'#15'btnTestIntegers'#4'Left'#2'w'#6'Height'#2#25#3'Top'#2#8#5'Width' - +#2'K'#7'Caption'#6#13'Test Integers'#7'OnClick'#7#20'btnTestIntegersClick'#8 + +'el__(Self):'#6#26' print( "delete", Self)'#6#27' def __add__(self, othe' + +'r):'#6'( return Foo(self.Value + other.Value)'#6#28' def Inc(Self, AVal' + +'ue = 1):'#6'$ Self.Value = Self.Value + AValue'#6#20' def GetSelf(Self)' + +':'#6#15' return Self'#6#21' def GetValue(Self):'#6#21' return Self.V' + +'alue'#6#28' def SetABC(Self, A, B, C):'#6#14' Self.A = A'#6#14' Self' + +'.B = B'#6#14' Self.C = C'#6#26' def Add(Self, AFooInst):'#6', Self.V' + +'alue = Self.Value + AFooInst.Value'#6#15'class Bar(Foo):'#6#28' def Inc(Se' + +'lf, AValue = 1):'#6'$ Self.Value = Self.Value - AValue'#6#14'def Add(a, ' + +'b):'#6#14' return a + b'#6#25'def MakeList(a, b, c, d):'#6#21' return [a,' + +' b, c, d]'#6#0#6#9'f = Foo()'#6#20'print( "Created", f)'#6#7'f.Inc()'#6#8'f' + +'.Inc(2)'#6#9'b = Bar()'#6#7'b.Inc()'#6#8'b.Inc(2)'#0#10'ParentFont'#8#8'Tab' + +'Order'#2#2#0#0#6'TPanel'#6'Panel2'#4'Left'#2#1#6'Height'#2'q'#3'Top'#3#152#1 + +#5'Width'#3#25#3#5'Align'#7#8'alBottom'#12'ClientHeight'#2'q'#11'ClientWidth' + +#3#25#3#10'ParentFont'#8#8'TabOrder'#2#3#0#7'TButton'#7'Button1'#4'Left'#2#15 + +#6'Height'#2#25#3'Top'#2#8#5'Width'#2'K'#7'Caption'#6#7'Execute'#7'OnClick'#7 + +#12'Button1Click'#10'ParentFont'#8#8'TabOrder'#2#0#0#0#7'TButton'#15'btnTest' + +'Integers'#4'Left'#2'w'#6'Height'#2#25#3'Top'#2#8#5'Width'#2'K'#7'Caption'#6 + +#13'Test Integers'#7'OnClick'#7#20'btnTestIntegersClick'#10'ParentFont'#8#8 +'TabOrder'#2#1#0#0#9'TCheckBox'#14'cbTestIntegers'#4'Left'#2'z'#6'Height'#2 - +#19#3'Top'#2')'#5'Width'#2'B'#7'Caption'#6#8'Included'#8'TabOrder'#2#2#0#0#0 - +#0#13'TPythonEngine'#13'PythonEngine1'#2'IO'#7#21'PythonGUIInputOutput1'#4'l' - +'eft'#2'`'#3'top'#2'0'#0#0#21'TPythonGUIInputOutput'#21'PythonGUIInputOutput' - +'1'#11'DelayWrites'#9#9'UnicodeIO'#8#9'RawOutput'#8#6'Output'#7#5'Memo1'#4'l' - +'eft'#3'R'#1#3'top'#2'0'#0#0#0 + +#24#3'Top'#2')'#5'Width'#2'Q'#7'Caption'#6#8'Included'#10'ParentFont'#8#8'Ta' + +'bOrder'#2#2#0#0#0#0#13'TPythonEngine'#13'PythonEngine1'#2'IO'#7#21'PythonGU' + +'IInputOutput1'#4'Left'#2'`'#3'Top'#2'0'#0#0#21'TPythonGUIInputOutput'#21'Py' + +'thonGUIInputOutput1'#11'DelayWrites'#9#9'UnicodeIO'#8#9'RawOutput'#8#6'Outp' + +'ut'#7#5'Memo1'#4'Left'#3'R'#1#3'Top'#2'0'#0#0#0 ]); diff --git a/PythonForDelphi/Demos/FPC/Demo25/unit1.pas b/PythonForDelphi/Demos/FPC/Demo25/unit1.pas index ad0c3a84..ac43c1c8 100644 --- a/PythonForDelphi/Demos/FPC/Demo25/unit1.pas +++ b/PythonForDelphi/Demos/FPC/Demo25/unit1.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, - StdCtrls, ExtCtrls, PairSplitter, PythonEngine, PythonGUIInputOutput; + StdCtrls, ExtCtrls, PairSplitter, PythonEngine, PythonGUIInputOutput,variants; type @@ -63,13 +63,13 @@ procedure TForm1.btnTestIntegersClick(Sender: TObject); Assert(VarIsPython(a)); Assert(VarIsPythonNumber(a)); Assert(VarIsPythonInteger(a)); - Assert(Integer(a) = 2); + Assert(StrToIntDef(Trim(VarToStr(a)), 0) = 2); b := VarPythonCreate(3); Assert(VarIsPython(b)); Assert(VarIsPythonNumber(b)); Assert(VarIsPythonInteger(b)); - Assert(Integer(b) = 3); + Assert(StrToIntDef(Trim(VarToStr(b)), 0) = 3); // arithmetic operations //---------------------- @@ -77,105 +77,105 @@ procedure TForm1.btnTestIntegersClick(Sender: TObject); // addition c := a + b; // check result of operation - Assert( Integer(c) = 5 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 5 ); // check that operation did not change the content of operands. - Assert(Integer(a) = 2); - Assert(Integer(b) = 3); + Assert(StrToIntDef(Trim(VarToStr(a)), 0) = 2); + Assert(StrToIntDef(Trim(VarToStr(b)), 0) = 3); // now with a litteral - c := a + b + 1; - Assert( Integer(c) = 6 ); - c := a + 1 + b; - Assert( Integer(c) = 6 ); - c := 1 + a + b; - Assert( Integer(c) = 6 ); + c := StrToIntDef(Trim(VarToStr(a)), 0) + StrToIntDef(Trim(VarToStr(b)), 0) + 1; + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 6 ); + c := StrToIntDef(Trim(VarToStr(a)), 0) + 1 + StrToIntDef(Trim(VarToStr(b)), 0); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 6 ); + c := 1 + StrToIntDef(Trim(VarToStr(a)), 0) + StrToIntDef(Trim(VarToStr(b)), 0); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 6 ); // substraction c := b - a; - Assert( Integer(c) = 1 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 1 ); // now with a litteral - c := b - a - 1; - Assert( Integer(c) = 0 ); - c := b - 1 - a; - Assert( Integer(c) = 0 ); - c := 1 - b - a; - Assert( Integer(c) = -4 ); + c := StrToIntDef(Trim(VarToStr(b)), 0) - StrToIntDef(Trim(VarToStr(a)), 0) - 1; + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 0 ); + c := StrToIntDef(Trim(VarToStr(b)), 0) - 1 - StrToIntDef(Trim(VarToStr(a)), 0); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 0 ); + c := 1 - StrToIntDef(Trim(VarToStr(b)), 0) - StrToIntDef(Trim(VarToStr(a)), 0); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = -4 ); // multiplication c := a * b; - Assert( Integer(c) = 6 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 6 ); // now with a litteral - c := a * b * 2; - Assert( Integer(c) = 12 ); - c := a * 2 * b; - Assert( Integer(c) = 12 ); - c := 2 * a * b; - Assert( Integer(c) = 12 ); + c := StrToIntDef(Trim(VarToStr(a)), 0) * StrToIntDef(Trim(VarToStr(b)), 0) * 2; + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 12 ); + c := StrToIntDef(Trim(VarToStr(a)), 0) * 2 * StrToIntDef(Trim(VarToStr(b)), 0); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 12 ); + c := 2 * StrToIntDef(Trim(VarToStr(a)), 0) * StrToIntDef(Trim(VarToStr(b)), 0); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 12 ); // integer division c := b div a; - Assert( Integer(c) = 1 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 1 ); // division: in Python a division between 2 integers is the same as the integer division c := b / a; - Assert( c = 1.5 ); - Assert( Integer(c) = 2 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 1.5 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 2 ); // modulus c := b mod a; - Assert( Integer(c) = 1 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 1 ); c := BuiltinModule.divmod(b, a); // this returns a tuple whose first item is the result of the division, // and second item the modulo. if VarIsPythonSequence(c) and (c.Length = 2) then begin - Assert(Integer(c.GetItem(0)) = 1); // division - Assert(Integer(c.GetItem(1)) = 1); // modulo + Assert( StrToIntDef(Trim(VarToStr(c.getitem(0))), 0) = 1); // division + Assert(StrToIntDef(Trim(VarToStr(c.getitem(1))), 0) = 1); // modulo end; // power c := BuiltinModule.pow(a, b); - Assert(c = 8); + Assert(StrToIntDef(Trim(VarToStr(c)), 0) = 8); // negation c := -a; - Assert( Integer(c) = -2 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = -2 ); // logical operations //------------------ // inverse c := not a; // in python it would be: c = ~2 - Assert( Integer(c) = -3 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = -3 ); // shift left (<<) c := a shl b; - Assert( Integer(c) = 16 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 16 ); c := a shl 1; - Assert( Integer(c) = 4 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 4 ); // shift right (>>) c := a shl b; c := c shr b; - Assert( Integer(c) = Integer(a) ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = StrToIntDef(Trim(VarToStr(a)), 0) ); c := b shr 1; - Assert( Integer(c) = 1 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 1 ); // and c := a and (a*5); - Assert( Integer(c) = Integer(a) ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = StrToIntDef(Trim(VarToStr(a)), 0) ); c := a and 6; - Assert( Integer(c) = Integer(a) ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = StrToIntDef(Trim(VarToStr(a)), 0) ); // or c := a or b; - Assert( Integer(c) = 3 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 3 ); c := a or 3; - Assert( Integer(c) = 3 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 3 ); // xor c := a xor b; - Assert( Integer(c) = 1 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 1 ); c := a xor 3; - Assert( Integer(c) = 1 ); + Assert( StrToIntDef(Trim(VarToStr(c)), 0) = 1 ); // comparisons //------------ diff --git a/PythonForDelphi/Demos/FPC/Demo31/Project1.lpi b/PythonForDelphi/Demos/FPC/Demo31/Project1.lpi index 9645cf5e..6cda066e 100644 --- a/PythonForDelphi/Demos/FPC/Demo31/Project1.lpi +++ b/PythonForDelphi/Demos/FPC/Demo31/Project1.lpi @@ -1,7 +1,7 @@ - + @@ -15,9 +15,6 @@ - - - @@ -46,7 +43,7 @@ - + @@ -56,9 +53,10 @@ - - - + + + + @@ -69,17 +67,16 @@ - + - + - @@ -95,7 +92,6 @@ - @@ -104,9 +100,7 @@ - - @@ -135,7 +129,6 @@ - @@ -144,7 +137,6 @@ - @@ -161,7 +153,6 @@ - @@ -185,9 +176,7 @@ - - @@ -238,8 +227,6 @@ - - diff --git a/PythonForDelphi/Demos/FPC/Demo31/Project1.res b/PythonForDelphi/Demos/FPC/Demo31/Project1.res index e66ecf85..bc23f8c7 100644 Binary files a/PythonForDelphi/Demos/FPC/Demo31/Project1.res and b/PythonForDelphi/Demos/FPC/Demo31/Project1.res differ diff --git a/PythonForDelphi/Demos/FPC/Demo31/Unit1.lfm b/PythonForDelphi/Demos/FPC/Demo31/Unit1.lfm index c8223e84..2c34cee3 100644 --- a/PythonForDelphi/Demos/FPC/Demo31/Unit1.lfm +++ b/PythonForDelphi/Demos/FPC/Demo31/Unit1.lfm @@ -2,19 +2,19 @@ object Form1: TForm1 Left = 659 Height = 647 Top = 47 - Width = 685 + Width = 668 VertScrollBar.Range = 210 ActiveControl = Memo1 Caption = 'Form1' ClientHeight = 647 ClientWidth = 668 Color = clBtnFace + DesignTimePPI = 134 Font.Color = clWindowText Font.Height = 11 Font.Name = 'MS Sans Serif' Font.Pitch = fpVariable OnCreate = FormCreate - LCLVersion = '0.9.30.2' Visible = True object Splitter1: TSplitter Cursor = crVSplit @@ -66,7 +66,7 @@ object Form1: TForm1 ' self.Height = 400' '' ' def btnCloseClick(self, Sender):' - ' print "Close!"' + ' print("Close!")' ' self.Close()' '' ' def MyFormCloseQuery(self, Sender, CanClose):' @@ -78,7 +78,7 @@ object Form1: TForm1 ' def grdTestDrawCell(self, Sender, Col, Row, Rect, State):' ' if gdSelected in State:' ' Sender.Canvas.Brush.Color = clBlue # 0x00ff0000 # blue' - ' print "Cell[%d, %d] is selected, Rect=%s, State=%s" % (Col, Row, Rect, State)' + ' print ("Cell[%d, %d] is selected, Rect=%s, State=%s" % (Col, Row, Rect, State))' ' Sender.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, "%d @ %d" % (Col, Row))' '' ' def grdTestSelectCell(self, Sender, Col, Row, CanSelect):' @@ -102,8 +102,8 @@ object Form1: TForm1 ' self.assertEqual(DVar.IValue, 70)' ' MainForm.Caption = ''PyDelphi rocks!'' #setting properties' ' self.assertEqual(MainForm.Caption, ''PyDelphi rocks!'')' - ' print' - ' print ''MainForm.ActiveControl='', MainForm.ActiveControl # class properties' + ' print()' + ' print( ''MainForm.ActiveControl='', MainForm.ActiveControl) # class properties' ' MainForm.BorderStyle = ''bsSizeable'' #enumeration property' ' MainForm.Anchors = [''akTop'', ''akLeft''] #set property' ' self.assertEqual(MainForm.Anchors, [''akTop'', ''akLeft''])' @@ -117,23 +117,23 @@ object Form1: TForm1 ' DVar.SetMeUp(''Age'', 25)' ' self.assertEqual(DVar.SValue, ''Age'')' ' self.assertEqual(DVar.IValue, 25)' - ' print' - ' print DVar.DescribeMe() #method calls' + ' print()' + ' print( DVar.DescribeMe()) #method calls' '' ' def testRepr(self):' - ' print' - ' print ''Representation of Delphi objects''' - ' print DVar' - ' print MainForm' + ' print()' + ' print (''Representation of Delphi objects'')' + ' print (DVar)' + ' print (MainForm)' ' if DelphiVersion >= 7:' - ' print DVar.DescribeMe # method object' - ' print DVar.SL # TStrings' + ' print (DVar.DescribeMe) # method object' + ' print (DVar.SL) # TStrings' '' ' def testTStrings(self):' ' SL = DVar.SL' ' self.assertEqual(len(SL), 2)' - ' print' - ' for i in DVar.SL: print i, '' contains '', DVar.SL[i]' + ' print()' + ' for i in DVar.SL: print (i), '' contains '', DVar.SL[i]' ' SL.Add(''New String'')' ' self.assertEqual(len(SL), 3)' ' self.assertEqual(SL.IndexOf(''New String''), 2)' @@ -148,7 +148,7 @@ object Form1: TForm1 ' self.assertEqual(MainForm in SL.Objects, True)' ' SL.Delete(2)' ' self.assertEqual(len(SL), 2)' - ' print "str(SL) =", str(SL)' + ' print ("str(SL) =", str(SL))' ' SL.Assign([1, 2, 3])' ' self.assertEqual(len(SL), 3)' ' self.assertEqual(''2'' in SL, True)' @@ -180,7 +180,7 @@ object Form1: TForm1 ' self.assertEqual(MainForm.Button1.Caption, ''Click me!!!!'')' ' # Test Owner property and DelphiObject comparison' ' self.assert_(MainForm.Button1.Owner == MainForm)' - ' print [i.Name for i in MainForm.Components]' + ' print ([i.Name for i in MainForm.Components])' '' ' def testCreateComponent(self):' ' NewButton = CreateComponent(''TButton'', None)' @@ -191,9 +191,9 @@ object Form1: TForm1 '' ' def testWinControls(self):' ' self.assertEqual(MainForm.Panel1.Parent, MainForm)' - ' print' - ' print ''MainForm contains '', MainForm.ControlCount, '' controls''' - ' print [i.Name for i in MainForm.Controls]' + ' print()' + ' print (''MainForm contains '', MainForm.ControlCount, '' controls'')' + ' print ([i.Name for i in MainForm.Controls])' '' ' def testForm(self):' ' MyForm = CreateComponent(''TForm'', None)' @@ -246,7 +246,7 @@ object Form1: TForm1 ' B2.ModalResult = mrOk' ' B2.TabOrder = 3' ' def ClickHandler(Sender):' - ' print Sender.Name, '' was clicked''' + ' print (Sender.Name, '' was clicked'')' ' LB.Items.Add(Edit.Text)' ' B1.OnClick = ClickHandler' ' def KeyPressHandler(Sender, Key):' @@ -302,21 +302,21 @@ object Form1: TForm1 ' def testFormSubclass(self):' ' f = MyForm(Application)' ' try:' - ' print f.ShowModal()' + ' print (f.ShowModal())' ' finally:' ' f.Free()' '' ' def testFormSubclass2(self):' ' f = TTestForm(Application)' ' try:' - ' print f.ShowModal()' + ' print (f.ShowModal())' ' finally:' ' f.Free()' '' ' def testPointConversions(self):' ' p1 = Point(10, 10)' ' p = MainForm.ClientToScreen(p1)' - ' print p' + ' print (p)' ' p2 = MainForm.ScreenToClient(p)' ' self.assertEqual(p2.X, p1.X)' ' self.assertEqual(p2.Y, p1.Y)' @@ -324,7 +324,7 @@ object Form1: TForm1 ' def testObjectNotification(self):' ' DVar.IValue = 0' ' def ChangeHandler(Sender):' - ' print Sender' + ' print (Sender)' ' Sender.IValue = 55' ' DVar.OnChange = ChangeHandler' ' if DelphiVersion >= 7:' @@ -343,7 +343,7 @@ object Form1: TForm1 ' MainForm.actTest.Execute()' ' self.assertEqual(DVar.IValue, 1)' ' def ActionHandler(Sender):' - ' print "Action", Sender.Name, "executed from Python"' + ' print ("Action", Sender.Name, "executed from Python")' ' DVar.IValue = 2' ' self.assertEqual(MainForm.actTest.OnExecute, None)' ' MainForm.actTest.OnExecute = ActionHandler' @@ -371,8 +371,8 @@ object Form1: TForm1 ' MainForm.Button1.SetFocus()' ' self.assertEqual(Screen.ActiveControl, MainForm.Button1)' ' def ActiveControlChangeHandler(Sender):' - ' print "ActiveControlChangeHandler fired"' - ' print "New active constrol is", Sender.ActiveControl.Name' + ' print ("ActiveControlChangeHandler fired")' + ' print ("New active constrol is", Sender.ActiveControl.Name)' ' DVar.IValue = 2' ' self.assertEqual(Screen.OnActiveControlChange, None)' ' Screen.OnActiveControlChange = ActiveControlChangeHandler' @@ -402,10 +402,8 @@ object Form1: TForm1 ' except SystemExit:' ' pass' ' MainForm.ActiveControl = MainForm.Memo2 # Class property!' - '' - ' ' - ' ' ) + ParentFont = False ScrollBars = ssVertical TabOrder = 0 end @@ -418,6 +416,7 @@ object Form1: TForm1 BevelOuter = bvNone ClientHeight = 41 ClientWidth = 668 + ParentFont = False TabOrder = 1 object Button1: TButton Left = 8 @@ -426,6 +425,7 @@ object Form1: TForm1 Width = 75 Caption = 'Execute' OnClick = Button1Click + ParentFont = False TabOrder = 0 end end @@ -435,13 +435,14 @@ object Form1: TForm1 Top = 0 Width = 668 Align = alTop + ParentFont = False ScrollBars = ssBoth TabOrder = 2 end object PyEngine: TPythonEngine IO = PythonGUIInputOutput1 - left = 16 - top = 16 + Left = 16 + Top = 16 end object PythonModule: TPythonModule Engine = PyEngine @@ -455,19 +456,19 @@ object Form1: TForm1 end> ModuleName = 'spam' Errors = <> - left = 56 - top = 16 + Left = 56 + Top = 16 end object PythonGUIInputOutput1: TPythonGUIInputOutput UnicodeIO = False RawOutput = False Output = Memo2 - left = 168 - top = 17 + Left = 168 + Top = 17 end object ActionList1: TActionList - left = 96 - top = 80 + Left = 96 + Top = 80 object actTest: TAction Caption = 'Test' OnExecute = actTestExecute diff --git a/PythonForDelphi/Demos/FPC/Demo31/Unit2.lfm b/PythonForDelphi/Demos/FPC/Demo31/Unit2.lfm index 75d6772b..76dbe787 100644 --- a/PythonForDelphi/Demos/FPC/Demo31/Unit2.lfm +++ b/PythonForDelphi/Demos/FPC/Demo31/Unit2.lfm @@ -3,24 +3,28 @@ object TestForm: TTestForm Height = 341 Top = 200 Width = 614 + ActiveControl = CheckBox1 ClientHeight = 341 ClientWidth = 614 - LCLVersion = '1.5' + DesignTimePPI = 134 + Visible = False object CheckBox1: TCheckBox Left = 96 - Height = 22 + Height = 24 Top = 16 - Width = 91 + Width = 96 Caption = 'CheckBox1' + ParentFont = False TabOrder = 0 end object CheckBox2: TCheckBox Left = 96 - Height = 22 + Height = 24 Top = 56 - Width = 91 + Width = 96 Caption = 'CheckBox2' Checked = True + ParentFont = False State = cbChecked TabOrder = 1 end @@ -31,13 +35,15 @@ object TestForm: TTestForm Width = 75 Caption = 'Close' OnClick = btnCloseClick + ParentFont = False TabOrder = 2 end object Edit1: TEdit Left = 96 - Height = 25 + Height = 28 Top = 96 Width = 121 + ParentFont = False TabOrder = 3 Text = 'Edit1' end @@ -47,9 +53,9 @@ object TestForm: TTestForm Top = 48 Width = 249 ItemHeight = 0 + ParentFont = False ScrollWidth = 247 TabOrder = 4 - TopIndex = -1 end object btnAdd: TButton Left = 104 @@ -57,6 +63,7 @@ object TestForm: TTestForm Top = 128 Width = 75 Caption = 'Add' + ParentFont = False TabOrder = 5 end end