LabVIEW Radio Buttons without Frames

Aug 26th, 2010 by Christina in LabVIEW, User Interface
Radio Button Group Example

Radio Buttons

The intended purpose of a radio button group is to select one (and only one) option from a set of choices. Microsoft has a detailed article on radio button usage guidelines on MSDN. (Although I should note that I don’t agree with all their guidelines).

LabVIEW introduced the radio buttons control in version 7.1. [Before then you had to write diagram code to ensure that only one radio button in a group was TRUE at a time, which was very annoying. Individual radio buttons are still in the palettes and I sometimes see them being used inappropriately, e.g. in place of a checkbox].

Unfortunately, the radio buttons control is somewhat confusing to new users. Here are the basics:

  • The group of radio buttons is a single control, with a single terminal on the diagram. Like a cluster, you don’t get terminals for the controls inside the group.
  • The radio buttons value is an enumeration of the contained button labels.
  • Similar to a cluster, you add radio buttons by placing them inside the bounds of the group. (You can also right-click on the group border and select Add Radio Button).

One point of frequent confusion is that the radio buttons look very different when initially placed from the palette than you probably want them to look in your UI:

Radio Buttons

Radio buttons placed from palette

You usually have to perform the following steps for every radio button group:

  • Add more radio buttons, if necessary.
  • Set the label of each radio button, as you want it to appear in your value enumeration.
  • Hide the label of each radio button.
  • Set the boolean text for each radio button.
  • Adjust or hide the frame.
  • Set a group label.
  • If the group label is on top of a frame, adjust its colors. [See previous blog entry for details of coloring labels on frames].

You’ll notice that I mentioned that you could “hide the frame.” Many people conclude they can’t hide the frame when they can’t delete it or color it transparent. The trick is, although you can’t color the Modern or System style frames, you can color the Classic one.

You may notice in the Microsoft guidelines, that it’s usually preferable not to have a frame around a radio button group. In many cases, frames add unneeded visual clutter. So, for your convenience, here is a sample (saved in LabVIEW 2009) of a radio button group with no frame: Frameless Radio Buttons.vi

Radio Buttons with no frame

There are some things to be aware of when using this control:

  • The background of the group is opaque so that you can see where the edge is in case you want to use right-click menu items.
  • The radio buttons group is set to automatically “Arrange Vertically.”
    • The auto-arranging makes it easy to add new radio buttons and have them placed properly.
    • The auto-arranging avoids the problem of the invisible frame clipping the radio button boolean text.
    • Unfortunately, however, the frame does not resize while you are editing the radio button boolean text. If you type longer text into it, it will be cut off until you finish the text edit.
  • Each radio button in this group has a small, extra decoration so that they meet the Microsoft spacing guideline when auto-arranged vertically.
    • To add more radio buttons and maintain the spacing, use the right-click menu item Add Radio Button or duplicate one of the radio buttons in the group.
  • To customize the item names of the group’s enumeration, you have to show the label of each radio button, edit it, and hide it again. You may prefer to make your own starting version with all the labels visible.

9 Comments

  • There are some alternatives for radio buttons (I was an LV 7.0 user for a long time):

    1. You can use a listbox.
    2. You can use a numeric slider and customize it to have text instead of numbers.
    3. You can even use a ring, which provides a different UI model.

    The big advantage (especially with the listbox) is that you can change the data at run-time. The big disadvantage is that the data type is not strict like an enum and that it’s not a standard UI element like a radio button.

    I have to admit I never used a radio button. Either because I’m used to it or because I have existing code I build upon or because it suits the kind of GUIs (e.g. touch screen apps) I make better, I always ended up using one of the other options when wanting the user to select one option of several.

    P.S. You can hide modern frame – what you need to do is right click it with the coloring tool, then toggle the coloring tool to change both the FG and BG colors. The easiest is by clicking the space bar while the color dialog is shown.

  • We have 2 great LabVIEW positions, please check the website page and let us know if you or any one is interested. These positions are bases in Minneapolis.

  • Yair,

    You’re right, there are other UI elements that do similar work as radio buttons. The MSDN article discusses many in the “Is this the right control?” section.

    You can change the radio button boolean text at run-time, so I don’t think that’s a reason to use a listbox over radio buttons. Having eight or more options would definitely make me choose a listbox over radio buttons, however. I tend to choose drop-down rings if the ability to browse the list is less important than minimizing the area of the screen the control takes, or if the option should rarely be changed.

    PS, Thanks for the coloring tip! I never noticed that you could color those frames by toggling to the foreground color, because I always customize controls from the Classic palette. Even after coloring, however, the Modern frame is very wide, so it’s still a good idea to use the Classic version for the transparent case.

  • Bennett – I recommend you post your job offerings on the LabVIEW Career Network and LAVA forums, where they can reach a wider audience.

  • I am trying to implement a GUI (LabView 8.0) to do a mutually exclusive selection from 8 preset radio frequencies. So obviously I thought of using “radio” buttons.

    However, I would like to load the button labels (frequency values) from an external file, when the vi starts up. Then the button block must output the selected frequency value to the associated control functionality.

    I know how to read a file and extract individual initialization parameters from it. So initializing each button from a numeric, and outputting the selected value is all I need.

    Can this be done with radio buttons? Any chance of a sample/example vi?

    Thanks in advance!

  • Stepper – if I understand your application correctly, I believe you just need to set the radio button captions and/or boolean text to the labels from you file, and then use the enum result of the radio selection to index your array of values. Note that you can’t set the label of the radio buttons at run-time because that would change the data type of the radio button enum. I’ll try to make a quick example when I get a chance.

  • Hi Christina,

    that would be great!

    Yes, the button labels/captions should correspond to the values from the file, and the radio button selection output should be used to pass the value associated with the selected button to the downstream function.

    I have been trying some more approaches, without much “luck”…

    This is as far as I got:
    http://www.nonstopsystems.com/radio/radio-button-trials2.vi

    The external .lvm data file that I use simply has 8 values in it, e.g.:

    3579
    3604
    7040
    7080
    10140
    14063
    14074
    14230

    Thanks in advance!

  • Stepper,

    I think this should do what you’re looking for: http://blog.eyesonvis.com/wp-content/uploads/2010/11/radio-button-trials3.vi

    Note that it’s better to have the radio button Boolean text visible than the Captions, because users can click the Boolean text to select the item.

  • Hi Christina,

    YESSSSSSSSSSS! That is exactly what I am looking for!

    Perfect! Thanks you VERY much for your help!

 

Comments have been closed for this post.