pier 4 Posted March 8, 2021 Hi! Do you believe it is feasible to show some python graphics, say from matplotlib, and the "hook" the window and make it "live" inside a panel of a Delphi application? (when the panel moves/resizes the window moves/resizes with it)? If so is any code for doing this available? (if not I will write it) Thanks for any suggestion Share this post Link to post
pyscripter 694 Posted March 8, 2021 See python4delphi/Tutorials/Webinar II at master · pyscripter/python4delphi (github.com) Both video and source code. Share this post Link to post
pier 4 Posted March 8, 2021 (edited) Thank you so much for your reply. I was aware of the possibility of using the SVG output of matplotlib (which I will use as an intermediate solution), however this is not what I am looking for. matplotlib was just an example of a more general type of approach I am pursuing, i.e. "embedding"/"controlling" graphical output of python applications in order to make it appear more integrated within a Delphi application. Anyhow thank you again for your time and suggestion. Edited March 8, 2021 by pier Share this post Link to post
pier 4 Posted March 11, 2021 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; 4 Share this post Link to post
Talal Bader 0 Posted December 26, 2022 (edited) On 3/11/2021 at 2:26 PM, pier said: Windows.SetParent(plotwnd,(PageControl1.Pages[1] as TTabSheet).Handle); this might be stupid question :). I tried the code but windows showed as undefined, I could not find which library to add to uses to make it recognizable could you please give some details how to git it work thanks --- follow up. found it 🙂 it is: winapi.windows.setparent .......... thanks Edited December 26, 2022 by Talal Bader Share this post Link to post