UI Interest Group Blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Adding new UI objects to the front panel (and even link data) on Run-Time :)

~Samuli
Member

Hello all!

So is it really possible to add any new UI objects to your user interface during run-time and even link data to those new objects? Yeah it is! If you use some nice tricks I made this demo for Northern Europe NIDays last year and I just wanted to share it with our UI Community. The code is pretty simple and I made it for demo purpose only. So it's not ready application with proper error handling etc but you will find some cool functions there that you can reuse with your projects. I tried to keep the code as clean as possible so it should be pretty easy to understand how it works.

With this demo you can add new LabVIEW UI objects to the Front Panel and move those objects around with your right mouse click (works best with LabVIEW 2011 btw. There is some feature in 2012 that will popup the right click menu to the objects even though it is disabled. You can hide the menu by clicking the Esc button during the movement if you use 2012.). you can also link data to these new objects (just watch the video how to do it).

Here is simple video that will show you how it works:

http://screencast.com/t/bRfa1iQfHx

If you have any questions please comment and I will try to answer those. Enjoy!

Best regards,

Samuli

Updated: Added also 2011 verision and fixed one linking problem.

Style is Everything
Download All
Comments
GerdW
Knight of NI

Hi Samuli,

when your example works "best with LV2011" then you should also attach a version for older LabVIEW versions. Right now it's just for LV2012...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
~Samuli
Member

Thanks! I uploaded also the 2011 version. There were also one linking problem that should be now fixed.

Style is Everything
Thoric
Trusted Enthusiast

This is cleverly done, well done to you sir. The code is well written and deserves credit.

But you should probably make everyone aware that this:

1. Uses pre-existing (empty) subpanel objects in the front panel that are hidden from view and brought into play for each required control.

1b. Therefore a user would need to create as many empty sub-panel objects as controls they think they might ultimately have an operator require, which could be many dozens.

2. Absolutely requires the full LabVIEW development environment to be present as LabVIEW needs to compile each manufactured control VI (so presumably this will not work in standalone executables).

It doesn't quite answer the holy-grail of "Creating Controls on the fly in the Run-Time environment", but it's the closest thing I've seen to date!

Thoric (CLA, CLED, CTD and LabVIEW Champion)


~Samuli
Member

Yeah subpanels are needed but empty subpanels wont take much memory so you could create XXXX of them there. And user should not be able to use as many anyway per one Front Panel Or you would need really big screen And in the end when the editing phase is ready you should then use scripting and create the UI with real UI components instead of subpanels. This example is more "editor" than real application. I just did not had time to create that phase even though it was my plan. It would also work as executable but then you would need some extra work

Style is Everything
TroyK
Active Participant

Very nice demonstration and a good example of neat coding style.

A couple of years back I had a similar thought to generate dynamic simulator virtual front panels.

We wanted to distribute a common "Virtual Front Panel" application to a number of projects who could then load a configuration and get a completely customized front panel for their project.

My idea was much more limited than yours and I never got around to implementing it.

Now that I've seen your demo though I may be inspired to revisit.

One tip I can offer: We have an interim solution working that loads a separate uncompiled VI into a subpanel of a compiled application on a computer that does NOT have the LabVIEW development environment installed. This seems to work fine. So perhaps having a bunch of saved controls in a resources subfolder may enable you to load them in your subpanels from a compiled executable at runtime without the LabVIEW development environment being present.

I do have one request, can you please upload your video to YouTube and embed it in your post. Unfortunately my company blocks screencast.com (as well as a bunch of other "online storage" sites) so I can't watch your video for a demonstration on how you intend it to be used.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
swatts
Active Participant

Nice work!,

ooh it's got me thinking now.

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile

Thoric
Trusted Enthusiast

TroyK wrote:


                       

One tip I can offer: We have an interim solution working that loads a separate uncompiled VI into a subpanel of a compiled application on a computer that does NOT have the LabVIEW development environment installed. This seems to work fine. So perhaps having a bunch of saved controls in a resources subfolder may enable you to load them in your subpanels from a compiled executable at runtime without the LabVIEW development environment being present.


                   

Yes, loading an existing VI into a subpanel will work with just the run-time environment because VIs contain the compiled binary already, which is what the run-time requires.

The code in this document uses scripting to create a VI on-the-fly, which must be compiled for it to be useable and therefore it cannot work without the development environment present. So yes, having a library of pre-created controls in a resource folder will work to some extent.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


EricC.
Active Participant

Hi

nice example

Yo sai that it work on run-time !

Or the run-time is only avaible on a exe

I build the executable and, of curse, it doesn't work because you use the scripting function and these function aren't avaible on run-time !!!!

EricC

Ingénieur d'Application / Développeur LabVIEW Certifié (CLD)
Application Engineer / LabVIEW Certified Developer (CLD)
~Samuli
Member

Yes it would work as exe but you need some work as we said previously You need to have those UI objects ready.

Style is Everything
Ben
Knight of NI Knight of NI
Knight of NI

For those that need to "Create Control on the Fly" in an exe...

Search the Developer Exchange for "Controls of the fly".

I have multiple posts on that topic (including examples) and will not repeat myself here.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel