I'd like to display an image of Python's matplotlib graph in the GUI created by VisualStudio(C#).

Asked 2 years ago, Updated 2 years ago, 75 views

What I want to do is follow the title, and I would like to know how to display images of matplotlib graphs on the screen created by VisualStudio's .NETFramework.
The flow is
Click the button on the GUI
→ Python scripts (scripts that draw graphs) run
→ Get Graphic Images
→ Display image in GUI
That's the flow.

I looked it up and found out that I used interprocess communication, but I didn't know exactly how to do it, whether I didn't study enough or not.
If you know a simpler way, please let me know.
Or, if you know any good websites, please let me know.

You can write the code directly.
Thank you for your cooperation.

python c# visual-studio .net matplotlib

2022-09-30 17:15

2 Answers

Click the button on the GUI
→Python scripts (scripts that draw graphs) run

You can launch another program from the .net application using System.Diagnostics.Process.Start.Now launch python and print the image to the appropriate directory.

→ Get Graphic Images
→ Display image on GUI

The PictureBox control is easy to use to view images in the .net application.ImageLocation property, please specify the path of the image you just printed.

Check the .Net reference for each usage.If there is anything you do not understand, please make it specific and ask a separate question.


2022-09-30 17:15

It seems to be different from what you looked into, but I think this is the most effective method right now.
Matplotlib python module, using from C#
It seems to be written that the web service is set up in Flask to implement Python+Matplotlib web-API and the result of throwing Http requests back from the C# app.

The GitHub project and NuGet package have also been created, so why not try it quickly?

There seems to be another way to use it.

IronPython: There seems to be a version of 2.x that requires a lot of action and an incomplete version of 3.x.
Use Python from Windows.NET C#.March 30, 2017. /IronPython/IronLanguages/ironpython3

Launch Python as a child process: The results of the Japanese article were displayed in a separate window.
C# to call PYTHON/Inter-process communication between C# and Python
execute a python script in C#

Python for .NET: If you're good at using it, you'll have the most freedom, but you're checking up to 3.6 to see if it works.
pythonnet.github.io/pythonnet/pythonnet
How to call .NET from Python and vice versa/Notes to users (O) of Python in Visual Studio
Python Plot does not appear when launched by Command Line in C#/add docs-using matplotlib from C# via pythonnet#442/"https://github.com/pythonnet/pythonnet/issues/410"rebounded-following ="reboundedore> available API#410


2022-09-30 17:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.