forked from Embarcadero/python4delphi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.pas
More file actions
67 lines (53 loc) · 1.38 KB
/
Unit1.pas
File metadata and controls
67 lines (53 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PythonEngine, PythonGUIInputOutput, StdCtrls;
type
TMySeq = class(TPyObject)
public
// Mapping services
function MpLength : NativeInt; override;
function MpSubscript( obj : PPyObject) : PPyObject; override;
//function MpAssSubscript( obj1, obj2 : PPyObject) : Integer; override;
end;
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
PythonEngine1: TPythonEngine;
PythonGUIInputOutput1: TPythonGUIInputOutput;
PythonModule1: TPythonModule;
PythonType1: TPythonType;
procedure Button1Click(Sender: TObject);
procedure PythonType1Initialization(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TMySeq }
function TMySeq.MpLength: NativeInt;
begin
Result := 10;
end;
function TMySeq.MpSubscript(obj: PPyObject): PPyObject;
begin
Result := obj;
GetPythonEngine.Py_XINCREF(obj);
end;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
PythonEngine1.ExecStrings(Memo2.Lines);
end;
procedure TForm1.PythonType1Initialization(Sender: TObject);
begin
with Sender as TPythonType do
PyObjectClass := TMySeq;
end;
end.