Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
112 lines (95 loc) · 2.99 KB

File metadata and controls

112 lines (95 loc) · 2.99 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
unit WrapDelphiDialogs;
{$I Definition.Inc}
interface
uses
Classes, SysUtils, PythonEngine, WrapDelphi, WrapDelphiClasses,
WrapDelphiControls, Windows, Dialogs, TypInfo;
type
TPyDelphiOpenDialog = class(TPyDelphiComponent)
private
function GetDelphiObject: TOpenDialog;
procedure SetDelphiObject(const Value: TOpenDialog);
protected
// Exposed Methods
function Execute_Wrapper(args: PPyObject): PPyObject; cdecl;
// Property Getters
function Get_filename(AContext: Pointer): PPyObject; cdecl;
public
class function DelphiObjectClass: TClass; override;
class procedure RegisterGetSets(PythonType: TPythonType); override;
class procedure RegisterMethods( PythonType : TPythonType ); override;
// Properties
property DelphiObject: TOpenDialog read GetDelphiObject
write SetDelphiObject;
end;
implementation
uses
WrapDelphiTypes;
{ Register the wrappers, the globals and the constants }
type
TDialogRegistration = class(TRegisteredUnit)
public
function Name: string; override;
procedure RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper); override;
procedure DefineVars(APyDelphiWrapper: TPyDelphiWrapper); override;
end;
{ TDialogRegistration }
procedure TDialogRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper);
begin
inherited;
end;
function TDialogRegistration.Name: string;
begin
Result := 'Dialog';
end;
procedure TDialogRegistration.RegisterWrappers(APyDelphiWrapper
: TPyDelphiWrapper);
begin
inherited;
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiOpenDialog);
end;
{ TPyDelphiOpenDialog }
class function TPyDelphiOpenDialog.DelphiObjectClass: TClass;
begin
Result := TOpenDialog;
end;
function TPyDelphiOpenDialog.GetDelphiObject: TOpenDialog;
begin
Result := TOpenDialog(inherited DelphiObject);
end;
function TPyDelphiOpenDialog.Execute_Wrapper(args: PPyObject): PPyObject;
begin
// We adjust the transmitted self argument
Adjust(@Self);
with GetPythonEngine do begin
if PyArg_ParseTuple( args, ':Execute') <> 0 then
Result := VariantAsPyObject(DelphiObject.Execute())
else
Result := nil;
end;
end;
function TPyDelphiOpenDialog.Get_filename(AContext: Pointer): PPyObject;
begin
Adjust(@self);
Result := GetPythonEngine.VariantAsPyObject(DelphiObject.FileName);
end;
class procedure TPyDelphiOpenDialog.RegisterGetSets(PythonType: TPythonType);
begin
inherited;
PythonType.AddGetSet('FileName', @TPyDelphiOpenDialog.Get_filename,
nil, '', nil);
end;
class procedure TPyDelphiOpenDialog.RegisterMethods(PythonType: TPythonType);
begin
inherited;
PythonType.AddMethod('Execute', @TPyDelphiOpenDialog.Execute_Wrapper,
'TOpenDialog.Execute()'#10 +
'Displays the dialog');
end;
procedure TPyDelphiOpenDialog.SetDelphiObject(const Value: TOpenDialog);
begin
inherited DelphiObject := Value;
end;
initialization
RegisteredUnits.Add(TDialogRegistration.Create);
end.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.