@@ -25,13 +25,11 @@ TForm1 = class(TForm)
2525 procedure FormCreate (Sender: TObject);
2626 procedure cbPyVersionsSelect (Sender: TObject);
2727 private
28- { Déclarations privées }
2928 PythonEngine1: TPythonEngine;
3029 PythonModule1: TPythonModule;
3130 PythonType1: TPythonType;
3231 PyVersions: TPythonVersions;
3332 public
34- { Déclarations publiques }
3533 procedure CreatePythonComponents ;
3634 end ;
3735
@@ -40,8 +38,8 @@ TForm1 = class(TForm)
4038 // Then it must override some methods, like the constructors,
4139 // the RegisterMethods and the type services' virtual methods.
4240 TPyPoint = class (TPyObject)
43- x, y : Integer;
44- Name : String;
41+ x, y: Integer;
42+ Name : String;
4543
4644 // Constructors & Destructors
4745 constructor Create( APythonType : TPythonType ); override;
@@ -96,7 +94,6 @@ procedure TForm1.CreatePythonComponents;
9694
9795 PythonEngine1.IO := PythonGUIInputOutput1;
9896
99-
10097 { TPythonModule }
10198 PythonModule1 := TPythonModule.Create(Self);
10299
@@ -131,8 +128,8 @@ procedure TForm1.CreatePythonComponents;
131128end ;
132129
133130procedure TForm1.FormCreate (Sender: TObject);
134- Var
135- PyVersion : TPythonVersion;
131+ var
132+ PyVersion: TPythonVersion;
136133begin
137134 PyVersions := GetRegisteredPythonVersions;
138135 for PyVersion in PyVersions do
@@ -143,7 +140,6 @@ procedure TForm1.FormCreate(Sender: TObject);
143140 end ;
144141end ;
145142
146-
147143// First, we need to initialize the property PyObjectClass with
148144// the class of our Type object
149145procedure TForm1.PythonType1Initialization (Sender: TObject);
@@ -163,7 +159,7 @@ constructor TPyPoint.Create( APythonType : TPythonType );
163159// Don't call the Create constructor of TPyPoint, because
164160// we call the inherited constructor CreateWith that calls
165161// the Create constructor first, and because the constructors
166- // are virtual, TPyPoint.Create will be automatically be called.
162+ // are virtual, TPyPoint.Create will automatically be called.
167163
168164constructor TPyPoint.CreateWith( PythonType : TPythonType; args : PPyObject );
169165begin
@@ -257,16 +253,16 @@ procedure TPyPoint.OffsetBy( dx, dy : Integer );
257253
258254function TPyPoint.DoOffsetBy ( args : PPyObject ) : PPyObject;
259255var
260- dx, dy : Integer;
256+ dx, dy: Integer;
261257begin
262258 with GetPythonEngine do
263259 begin
264260 // We adjust the transmitted self argument
265261 Adjust(@Self);
266262 // first we extract the arguments
267- if PyArg_ParseTuple( args, ' ii:Point.Offset' ,@dx, @dy ) <> 0 then
263+ if PyArg_ParseTuple( args, ' ii:Point.Offset' , @dx, @dy ) <> 0 then
268264 begin
269- // if it's ok, then we call the method that does the job
265+ // if it's ok, we call the method that does the job
270266 // with the correct arguments
271267 OffsetBy( dx, dy );
272268 // Finally, we return nothing
@@ -299,16 +295,15 @@ function TPyPoint.DoRaiseError( args : PPyObject ) : PPyObject;
299295
300296// ///////////////////////////////////////////////
301297
302-
303298procedure TForm1.Button1Click (Sender: TObject);
304299var
305- DelphiPoint : TPyPoint;
306- p : PPyObject;
300+ DelphiPoint: TPyPoint;
301+ p: PPyObject;
307302begin
308303 // Here's how you can create/read Python vars from Delphi with
309304 // Delphi/Python objects.
310305
311- // You should ask to the TPythonType to create an instance of its type
306+ // You should ask the TPythonType to create an instance of its type
312307 // because it will do some initialization. You can use CreateInstanceWith
313308 // if you want to transmit some Python arguments.
314309 // We receive a Python object pointer
@@ -317,10 +312,10 @@ procedure TForm1.Button1Click(Sender: TObject);
317312 // Then we cast the python object to the right delphi type
318313 DelphiPoint := TPyPoint( PythonToDelphi(p) );
319314 // We do some changes on the delphi object
320- DelphiPoint.X:= 10 ;
321- DelphiPoint.Y:= 20 ;
315+ DelphiPoint.X := 10 ;
316+ DelphiPoint.Y := 20 ;
322317 // Add variable "myPoint" in the module "spam".
323- // So you'll access to the var in the module called spam with:
318+ // So you'll have access to the var in the module called spam with:
324319 // import spam
325320 // print spam.myPoint
326321 PythonModule1.SetVar( ' myPoint' , p );
0 commit comments