06-08-2023 11:13 AM
Hello, I am just starting my adventure with LabView hence my question.
How do I make it so that when I press a button specifically in this case Square LED, it shows some specific picture? I am making something like a Restaurant Menu, I would like when I click a dish to order it to show a picture of it, is it possible to get this on Square LED or not though?
Greetings and thanks in advance
06-08-2023
11:42 AM
- last edited on
06-01-2025
05:04 PM
by
Content Cleaner
Well, yes, though typically a "Square LED" is an "Indicator" meaning you would use it as a data output, not something that you click on. Usually you would want something that is visually designed to appear clickable (button, switch, etc.)
Anyway, to trigger it you would want to use an event structure. See here for example:
https://www.ni.com/en/support/documentation/supplemental/06/event-driven-programming-in-labview.html
There's also code examples in your LabVIEW install, follow the directions on that page to get to them.
For showing the picture, do you need the ability to load the picture from a file or can you just put the a picture in your code and show that? Loading from a file is more complicated.
06-08-2023 12:48 PM
I created something like this:
https://ibb.co/gwWFFXY
And it works, it loads the image from the folder, however every time I fire up the program I have to enter the path to the file again. So if it's a more difficult option to choose to begin with, the option with dropping the image into the code and showing it would suffice.
06-08-2023
02:02 PM
- last edited on
06-01-2025
05:04 PM
by
Content Cleaner
You can use a flat square button and customize it to show different pictures for the false and true state. (DETAILS)
If you make it a control instead of an indicator, you can just click on it to flip between the two pictures (one could be blank), no code needed at all.
(ALSO: Please do not link to external sites riddled with advertisements and popups, you can embed images right in the forum posts, or even attach VIs if you want)
06-09-2023 09:32 AM
You can make the path as a constant (or read from a ini file) so you don't have to insert the path everytime.
To change the image of a boolean check this other post
programatically change button image - NI Community
06-09-2023 09:43 AM - edited 06-09-2023 09:44 AM
An even simpler way would be to customize the button so the TRIE state is transparent, then paste the image as background in the front panel underneath.
Now you only need one customized button. You can even place it inside an array or cluster container (transparent container background) and have an entire row or column of such buttons, covering a long imager strip containing a series of image tiles.
06-09-2023 09:59 AM
@altenbach wrote:
An even simpler way would be to customize the button so the TRIE state is transparent, then paste the image as background in the front panel underneath.
Here's how that could look like. No code needed at all!