LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a "front page menu"

Solved!
Go to solution

If I want to have a menu at the begining of my VI, to let the person choose what function they want to use, how would I do that?

 

Lets assume that each function has a very large front panel with different controls and indicators, so you need the fropnt panel to look completelyu different depending on what function they intend to use.

 

The only way I can think of doing it, would be to use a property node to disable or enable certain controls and indicators depending on which function the user selects, but that seems very long winded and would mean having loads of empty gaps since you can't place two controls or indicators in the same space.

 

Is there any sort of "page" system where you can have multiple "pages" on your front panel, and design each "page" for a different function?

 

As an example, lets say the front page said "welcome to this program, please enter a username and password" and after that "choose from the following options", and then clicking option 1 brought up an oscilloscope, option 2 a power supply, option 3 another type of control or instrumentation etc.

 

If you had to have it all on one page with property nodes, it would be too big.

0 Kudos
Message 1 of 19
(4,721 Views)
Solution
Accepted by David-Baratheon

Sounds like a SubPanel is just what you're looking for. Each 'page' or panel is simply a VI which gets loaded into the SubPanel control. This way all controls and indicators are kept separate in their own VI, keeping everything nice and clean in the top level VI. It requires a bit of management framework, with the top level VI swapping VI references in and out of the SubPanel control, but the benefits far outweigh the disadvantages.

 

Another method is to use a tab control and hide the tabs, then programmatically switch between tabs based on user input. I'm not a big fan of this method as you still have all of the controls and indicators present in a single VI, but it at least separates them visually, rather than hiding and showing individual controls.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 2 of 19
(4,713 Views)
Solution
Accepted by David-Baratheon

Subpanels are awesome for this sort of thing...but to get them to work effectively you should think about completely splitting your application code from your presentation code (this is sometimes referred to as Model-View-Controller). Essentially you should have all of your application code/logic (i.e. DAQ, data processing, logging etc.) separated from your user interface. This means that you can very easily create multiple user interfaces with completely different controls/indicators/layouts that all connect to your 'application' code.

 

An even simpler solution to subpanels would be just to show/hide the front panels of the different function VIs when the user selects something from the menu...for example:

 

- On launch, show the menu VI

- When the user selects an option, show the front panel of the function VI (and optionally hide the menu VI)

- When they close the front panel of the function VI (using the panel close? filter event), show the menu again

etc.

 

Using subpanels would allow you to do all of this in a single window which is generally gives a more 'integrated' user interface but subpanels can sometimes be a bit finicky.

 

I wrote a post about 'dynamic tabs' and loading different VIs into subpanels here: https://decibel.ni.com/content/docs/DOC-42925


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 3 of 19
(4,705 Views)

Ok thanks guys, I will give that a go and see how I get on with it.

 

I found a good guide here that I will use to get me started, in case this thread comes up in anyone elses searches:

 

http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/loading_panel_in_subpanel/

 

http://digital.ni.com/public.nsf/allkb/D587067E18E0E70186256D44007B91FE

 

I'll post my code here that I managed to come up with

0 Kudos
Message 4 of 19
(4,682 Views)

Either pop up VI's according to the menu (you can hide the menu vi while the other runs), a tab control (which is easy to implement and i know a couple here dont quite like it) or sub panels, which has the same functionality but keeps each VI simpler.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 19
(4,666 Views)

A tab control allows for this kind of thing too. You should take a look at the tab control.

Tim
GHSP
Message 6 of 19
(4,648 Views)

Hi everyone, thanks for the suggestions and advice. 

 

I will give it a go with all three methods as a learning exercise.

 

I'll start with the subpanel since that seems the most prefferred method.

 

So far, I have used the NI tutorial to successfully port one VI into the sub panel.

 

So now I need to figure out how to get push buttons to control which VI is loaded into the subpanel. 

 

I was thinking of using case structures for that.

 

I wanted to use push buttons, so wondered if there was a way to alter a case structure based on which push button was pressed? I've attached an image of my set-up. The 5 bolean push buittons I need to somehow connect to a case structure that can determine which button has been pressed. Any suggestions?

 

When another project is referenced for a sub-panel, will that other project be included when a zip file or EXE or installer is produced?

 

I have also attached my code as a zip file.

 

How to use push buttons.png

 

0 Kudos
Message 7 of 19
(4,596 Views)

Use an event structure to determine which button has been pressed and use that information to insert a new VI into the subpanel. You can either register an event case for each button individually, or register for all 5 and then use the name of the control to determine which VI to insert.

 

As for 'when another project is referenced for a subpanel....' - unless you have a specific reason for using multiple projects, I would put it all into a single project in a single folder to avoid having files referenced as absolute paths (because they are outside the root directory of the project).

 

To make sure the files get included in the executable, you can either use a static VI reference instead of a path to the VI so the files are automatically included, or you will need to add the files to the 'always include' part of the build specification when you make your executable.


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 8 of 19
(4,586 Views)

Ok thanks. How do I register the push button for the case structure?

 

I was thinking something along the lines of a binary value 00000 where 00001 would be a case structure, 00010 would be a case structure etc. But I don't know how to link the five push buttons together and create a binary value. Or is there another way I would tackle this?

 

I need some way to "multiplex" my five push buttons as I cant connect them all together to the case structure

0 Kudos
Message 9 of 19
(4,580 Views)

Here are your two options... (and also how to add event cases)

 

One case for each button:

 

2015-09-21_10-03-20.png

 

One case for all buttons, and how to tell which button was pressed:

2015-09-21_10-05-10.png

 

I suggest you have a look at some of the Event examples or see if you can find some tutorials on the event structure!


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 10 of 19
(4,568 Views)