In case somebody is interested this is how I managed to nicely integrate matplotlib figures inside my delphi app.
1) the pythons script shows the plot with "plt.show(block=False)"
2) this is the code which executes the script and embeds the plot
procedure TForm1.Button1Click(Sender: TObject);
var plotwnd:HWND;
begin
PythonEngine1.ExecStrings( Synedit1.Lines );
plotwnd:=Findwindow(nil,'Figure 1');
if plotwnd<>0 then
begin
Windows.SetParent(plotwnd,(PageControl1.Pages[1] as TTabSheet).Handle);
SetWindowLong(plotwnd, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and not WS_BORDER and not WS_SIZEBOX and not WS_DLGFRAME );
showwindow(plotwnd,sw_showmaximized);
setforegroundwindow(plotwnd);
end;
end;
the plot is displayed inside a tabsheet which has an event handler to automatically resize the plot
procedure TForm1.PlotResize(Sender: TObject);
begin
movewindow(plotwnd,0,0,(PageControl1.Pages[1] as TTabSheet).Width,(PageControl1.Pages[1] as TTabSheet).Height,True);
end;