Skip to content

Commit 62b418c

Browse files
committed
Including the ShowMessage procedure
1 parent 2708b16 commit 62b418c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Source/vcl/WrapVclDialogs.pas

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,42 @@ implementation
5050
uses
5151
WrapDelphiTypes;
5252

53+
{ Global Functions }
54+
function ShowMessage_Wrapper(pself, args: PPyObject): PPyObject; cdecl;
55+
var
56+
LMsg: string;
57+
begin
58+
with GetPythonEngine do
59+
begin
60+
if PyArg_ParseTuple(args, 's:ShowMessage', @LMsg) <> 0 then
61+
begin
62+
ShowMessage(LMsg);
63+
Result := GetPythonEngine.ReturnNone;
64+
end else
65+
Result := nil;
66+
end;
67+
end;
68+
5369
{ Register the wrappers, the globals and the constants }
5470
type
5571
TDialogRegistration = class(TRegisteredUnit)
5672
public
5773
function Name: string; override;
5874
procedure RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper); override;
5975
procedure DefineVars(APyDelphiWrapper: TPyDelphiWrapper); override;
76+
procedure DefineFunctions(APyDelphiWrapper : TPyDelphiWrapper); override;
6077
end;
6178

6279
{ TDialogRegistration }
80+
procedure TDialogRegistration.DefineFunctions(
81+
APyDelphiWrapper: TPyDelphiWrapper);
82+
begin
83+
inherited;
84+
APyDelphiWrapper.RegisterFunction(PAnsiChar('ShowMessage'), ShowMessage_Wrapper,
85+
PAnsiChar('ShowMessage_Wrapper()'#10 +
86+
'Show a custom message as a dialog box.'));
87+
end;
88+
6389
procedure TDialogRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper);
6490
begin
6591
inherited;

0 commit comments

Comments
 (0)