LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building dynamic UIs with subVIs and sub panels

I try to build a database-driven application, where UI elements/controls on front panels are populated dynamically based on data from database queries. I would NOT like to build UIs at design time which have all possible controls pre-defined and are shown/hidden dynamically. I am currently experimenting with subVIs placed at runtime in a sub-panel. Where the code works expected if I only place one subVI-instance in the sub-panel, I am not successful with placing multiple instances of one subVI in one sub-panel. Note: I would NOT like to have hard-coded sub-panels for each instance of the subVI. How do I do this? Is this possible at all?

 

Currently my code looks like this:

Bildschirmfoto 2021-09-28 um 11.00.40.png

 The code works in a sense that the subVI is placed three times in the sub-panel, each instance below the other. However, the instance created in the previous loop becomes invisible or is destroyed as soon as a new instance is placed in the subVI.

 

0 Kudos
Message 1 of 16
(634 Views)

A single subpanel can only contain a single VI's front panel. What you can do is place multiple subpanels into a another subpanel and load each of those with the instance you would like to display. Or, you can simply add some control which will allow you to switch between the instances and you swap them out to display the user desired instance.

 

I highly recommend that you look at MGI's Panel Manager package. It greatly simplifies your panel management.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 16
(626 Views)

Yeah, I feared this. Quite frustrating dynamic VIs with LabVIEW...

0 Kudos
Message 3 of 16
(617 Views)

+1 for the MGI Panel Manager. I use it for everything. It took me a couple hours for it to "click" but once it did, boy is it useful.

 

Keep track of the VI references you create with Open VI Reference, then you can call Insert VI Ref into the subpanel on each one. You could do this with a scrollbar to make it look like an array of subpanels, or a list to the side with names, then when the user clicks an item in the listbox that element is inserted into the subpanel. MGI's toolkit will help a little with the abstraction but it's pretty simple at its core, you just call Insert VI Ref on the VI Ref you want to see and it'll show.

 

And yes- subpanels can only contain one VI at a time. That's why your method isn't quite working.

 

Another nice toolkit is VIBox Xcontrols, which contains a tool to programmatically create as many tabs as you'd like at runtime.

0 Kudos
Message 4 of 16
(590 Views)

If you're willing to integrate a 3rd-party GUI toolkit instead of using native VI Front Panels, have a look at my LQ toolkit: https://jksh.github.io/LQ-Bindings/

 

The video below shows a dynamic, nested UI from 2:04 onwards.

 

Certified LabVIEW Developer
0 Kudos
Message 5 of 16
(555 Views)

@JKSH that looks awesome. What's the minimal Qt license you need to run it? Their website seems to say the minimum pricing is $329 a month or $4k a year for application development.

0 Kudos
Message 6 of 16
(530 Views)

@BertMcMahan wrote:

@JKSH that looks awesome. What's the minimal Qt license you need to run it? Their website seems to say the minimum pricing is $329 a month or $4k a year for application development.


Thanks!

 

The price you mentioned is for a commercial license which includes a support contract, bugfix priority, easy access to more platforms/devices, and licensing terms that are unavailable to open-source users -- among other benefits.

 

The LQ packages include Qt and Qwt under open-source licenses which can be used in a proprietary LabVIEW project. So you don't need to get Qt separately; just install it via NIPM (see https://jksh.github.io/LQ-Bindings/docs/ for a walkthrough)

 

nipm-packages-install-lq

 

Note: Qt is a huge toolkit and I've only exposed a small subset through the LabVIEW API so far. If you'd like to try out features which aren't available yet, let me know and I can make the relevant updates.

Certified LabVIEW Developer
Message 7 of 16
(515 Views)

Holy cow. I didn't realize the base was open source/free... that website sure made it look like you needed an expensive license.

 

This is definitely going on my short list of things to try.

0 Kudos
Message 8 of 16
(447 Views)

@BertMcMahan wrote:

Holy cow. I didn't realize the base was open source/free... that website sure made it look like you needed an expensive license.

 

This is definitely going on my short list of things to try.


It is unfortunate that the open source community is obscured from their main website, as it is quite substantial (interactive stats at https://qt-project.org ). In fact, the Maintainer of Qt Core works for Intel, not for the Qt Company.

 

Imagine if LabVIEW Champions, Knights of NI, and CLAs can submit contributions to the core LabVIEW source code!

Certified LabVIEW Developer
0 Kudos
Message 9 of 16
(357 Views)

Thanks JHSK, this looks awesome.

 

However, I will stay hard coded LabVIEW core for the moment as I am not sure what the implications will be if I use the lib you propose (maintenance, long term strategy, etc.)

0 Kudos
Message 10 of 16
(351 Views)