Skip to content

Commit 6d1eb70

Browse files
authored
Merge pull request pyscripter#189 from ReinierNL/update_demo34
Updates for demo 34
2 parents 26f1d21 + 59bb9fe commit 6d1eb70

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

Demos/Demo34/Demo34.dproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
7878
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
7979
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
80+
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
8081
</PropertyGroup>
8182
<PropertyGroup Condition="'$(Base_Win64)'!=''">
8283
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
@@ -87,6 +88,8 @@
8788
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
8889
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
8990
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
91+
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
92+
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
9093
</PropertyGroup>
9194
<PropertyGroup Condition="'$(Cfg_1)'!=''">
9295
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>

Demos/Demo34/Unit1.dfm

1.25 KB
Binary file not shown.

Demos/Demo34/Unit1.pas

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
131128
end;
132129

133130
procedure TForm1.FormCreate(Sender: TObject);
134-
Var
135-
PyVersion : TPythonVersion;
131+
var
132+
PyVersion: TPythonVersion;
136133
begin
137134
PyVersions := GetRegisteredPythonVersions;
138135
for PyVersion in PyVersions do
@@ -143,7 +140,6 @@ procedure TForm1.FormCreate(Sender: TObject);
143140
end;
144141
end;
145142

146-
147143
// First, we need to initialize the property PyObjectClass with
148144
// the class of our Type object
149145
procedure 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

168164
constructor TPyPoint.CreateWith( PythonType : TPythonType; args : PPyObject );
169165
begin
@@ -257,16 +253,16 @@ procedure TPyPoint.OffsetBy( dx, dy : Integer );
257253

258254
function TPyPoint.DoOffsetBy( args : PPyObject ) : PPyObject;
259255
var
260-
dx, dy : Integer;
256+
dx, dy: Integer;
261257
begin
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-
303298
procedure TForm1.Button1Click(Sender: TObject);
304299
var
305-
DelphiPoint : TPyPoint;
306-
p : PPyObject;
300+
DelphiPoint: TPyPoint;
301+
p: PPyObject;
307302
begin
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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy