04-27-2017 09:13 AM
Hello all,
I am looking for a way for when, I press a "Load" button. My vi takes in the parameters that I have set, such as a string, 2 double, etc. And dynamically creates a button on a grid with my given parameters. I know how to do the basics with LabVIEW such as passing parameters to another vi's, I am just asking about a way to create dynamic buttons on runtime. Thank you for your help.
Solved! Go to Solution.
04-27-2017 09:26 AM
What do you want to do with this button once you have it created? How will its terminal be connected in your LabVIEW block diagram?
You can't create buttons dynamically. They need to be created in a VI at edit time.
What you could do is have buttons created and hide them. Then when you want to "create" one, you make it visible and change its position by writing to its property nodes.
04-27-2017 09:46 AM
I want the button to be there with my string, and the correct min/max double on a grid, and If I click on it, a dialog asking if you want to delete it.
Okay, I will try doing that and get back to you. I understand you can not create buttons dynamically. So, how about a rectangular shape with my text in there on a grid from lets say, the x-axis being 0-10, and y-axis being 0-50.
If I went with the picture function vi's, how can I click on anywhere on the shape I created, and delete it.
And if I wanted to create again, I set in parameters, then press the "Load" button.
Sorry if I am being unclear, and thank you.
04-27-2017 10:11 AM
"Been there. Done that!"
See here for a paper that discusses one of the times I wrote a LV program with configurable GUIs.
This is an excellent project if you want to fully appreciate the work that NI has put into LV. Using the picture control you are only limited by your ability to manipulate images and the amount of time you want to devote to it being truly flexable. Click detection is JUST a mater of comparing mouse click locations with where you put the virtual control.
But before you go there...
First think if you can put an upper limit on the number and type of controls. If you can do that, then you can go the easier way and have a bunch of off-screen control that are hidden until you want them. Then move then to where you want, size and set them... much easier than starting from scratch and recreating LabVIEW in LabVIEW.
Read the paper I link above.
Ben
04-27-2017 10:37 AM
@flezt wrote:
...and dynamically creates a button on a grid with my given parameters.
Can you show us a graphical sketch how it all should look like?
You can generate anything using a picture indicator and then "interact" with it by getting mouse down coordinates, for example. No matter what, in the end the entire front panel is just a 2D array of pixels, just that LabVIEW typically takes care of some of the UI processing. 😄
04-27-2017 10:48 AM
No thread of this type is complete without Christian's art work.
Ben
04-27-2017 10:59 AM
Can you show us a graphical sketch how it all should look like?
Should be relatively easy to imagine this one. A grid with x and y axis where my dialog buttons will be "created in"(hide/unhide). And right next to that will be a couple of /parameters which should be the name, and horizontal x axis min/max. Maybe a numbering scheme for the Y axis, we'll see. But I can draw something up if you would really like. 🙂
04-27-2017 12:37 PM
something like this
04-27-2017 01:16 PM
This should get you started.
Thread with picture control examples.
Thread with event for Picture control Nugget.
Have fun!
Ben
04-27-2017 01:38 PM
I have a couple of things to add here. First is my very beta like Multi Panel Interface which was a proof of concept for semi-dynamic control creation, and rearrangement. Here is a video demo. It didn't get too far beyond that but the idea is you could register for data sources similar to VeriStand and add saving and loading panel config.
The other thing this reminded me of is the Toolbar Class I made a while ago. With it buttons can be created or manipulated on the fly, with PNG images as the source of each button. I could see this being useful on a user customizable UI where maybe all the functions of the software are available and a user can select what buttons and in what order should appear. Then that UI is made using a picture control and mouse events are tracked with the user events made. Still I don't think this is the same as what you are asking for but adding new buttons could be done.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord