LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Embedd an EXE / MatPlotLib Graph into LabView

Solved!
Go to solution

Hello,

this question is quite specific so I will try to explain it the easiest way I can.

I wrote a python script that uses Matplotlib to plot a live updating graph of some temperature and humidity values against time. When I run that program a window, also called a figure, is opened and the graph is displayed.

My question is if I can embedd this Window into labview, or if I can compile the python program to an EXE and then embedd it into labview. I heard that it is possible to embedd program windows into LabView but I have no clue how to do this.

Does anyone have a VI which can do this?

 

Thanks a lot,

 

Enzo

 

PS: I saw this somewhere so it is possible: http://www.screencast.com/t/LjlkYzTWKr8J

0 Kudos
Message 1 of 5
(6,826 Views)

I expect this is actually quite a broad question. An example similar (and solved) question is here: http://forums.ni.com/t5/LabVIEW/Can-i-use-Python-Matplotlib-with-labview/td-p/1687036

 

You can embed a few different components quite easily in LabVIEW - I would guess (wildly and without substantiation) that you can get python to output the figure into a .NET suitable container and then embed that, perhaps...

 

Certainly you can call the python script from inside LabVIEW, but embedding the resulting figure is presumably more difficult. What exactly do you need to happen? It might be that suitable workarounds can be found to make it a much simpler exercise.


GCentral
0 Kudos
Message 2 of 5
(6,796 Views)

Hey! Thanks for the reply. The example you linked did not really answer the question, as that guy just linked a tutorial on how to do simple stuff such as 1+1 in a python function and call it from LabView. What I want to do is exactly what you proposed. Implement a .net structure, such as this graph window of python into labview so i have this graph embedded into a user Interface in Labview.

Do I Need to convert the python program into an exe in order to make it a .net structure?

If not, how do I do it?

0 Kudos
Message 3 of 5
(6,774 Views)

Yeah, I thought the link wasn't that great but I didn't explore the linked (inside the link I added) posts that closely.

 

I spoke with a colleague today who uses matplotlib and he didn't have anything specific to give me beyond 'look at the documentation' for embedding matplotlib in another window, but he did suggest it might be easier to just draw the pictures then import those directly. Would that work for your use case? I don't know what your plots look like or if they need to be interactive in some clever ways.

 

If you only need the picture to be updating, you might have an easier time continuously writing new images using matplotlib, then loading those images in a 2D Picture as described here.

 

It shouldn't be too hard to programmatically generate file names to save to from matplotlib and load using Read from JPEG/Bitmap/PNG (and optionally delete old plots when you no longer need them) but I don't know if this is sufficient for your use case.

 

To get anywhere with an ActiveX/.NET container, I think you'll have to go quite a lot deeper. Information about matplotlib's backends can be found here, but it really doesn't give information that directly helps you get an image into another GUI (i.e. LabVIEW) - it just highlights that is the direction you'd need to go in to get somewhere. If you want to go down that rabbit-hole, this StackOverflow post might be helpful - Embedding matplotlib inside qt activex component.

 

 


GCentral
0 Kudos
Message 4 of 5
(6,769 Views)
Solution
Accepted by topic author EnzoC

I'm not a python guy, but I have experimented with putting windows on the front panel of VIs.  Here is one place where I put Notepad on the front panel.

 

http://forums.ni.com/t5/LabVIEW/How-to-run-an-exe-as-a-window-inside-a-VI/m-p/3113729#M893102

 

All interactions with at are just as they would be from running Notepad.  There isn't any communication between Notepad and LabVIEW so if you have a button in python that you want to have LabVIEW react to then you'll need something to handle that communication.

 

Also as for embedding the EXE file inside a VI that can also be done, but isn't as manageable as just calling the EXE.  I have an example over on LAVA on how to put 7-zip in a VI, and then call it.  This does make things more self contained so there is just a single VI to distribute which can have all your compiled python code in it.

0 Kudos
Message 5 of 5
(6,763 Views)