From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change the color of text sent to a status box on the front panel?

I feel this should be simple but I can't figure it out. I perform three tests. For each test I output either 'Test x Passed' or 'Test x Failed' as a text string. I concatenate the three strings with a carriage return and display them in a status box (a string indicator.)

I want to turn each line of text red or green depending on whether it passed or failed. So I could have:

test 1 passed

test 2 failed

test 3 passed

I can't see a way of doing this. Help me out please, experts of LabVIEW!

 

 

0 Kudos
Message 1 of 7
(2,790 Views)

Hi novice,

 

you can select parts of the text using property nodes, then change their font settings (including colour) using other property nodes...

 

I recommend to use a table or a listbox as this will simplify the text colour settings a lot!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,775 Views)

I agree a table would be much easier. Here is an example of how you could do it in a single string

Capture.PNGCapture.PNG

0 Kudos
Message 3 of 7
(2,768 Views)

That works great! Thank you!

 

Just one follow up question if I may ... when I feed the output string into a local variable the colors are lost. I'm using a local because I write to the 'status' text box from various places in the program.

 

I don't want to take up any more of your time, but if you have any suggestions I'd be grateful

 

0 Kudos
Message 4 of 7
(2,735 Views)

@another_novice wrote:

That works great! Thank you!

 

Just one follow up question if I may ... when I feed the output string into a local variable the colors are lost. I'm using a local because I write to the 'status' text box from various places in the program.

 

I don't want to take up any more of your time, but if you have any suggestions I'd be grateful

 


Without seeing your code we can't really say. However giving basic advise would be to structure your code so that UI handling and updates are centralized so you eliminate the need to use the local variables.



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
0 Kudos
Message 5 of 7
(2,731 Views)

You have to make sure the value of the string is updated before you start selecting parts of it. You could do this with a local variable and a sequence structure, or with a property node. The error wire below makes sure the For Loop doesn't run until the value of String has been updated. Property nodes are a bit slower, but if this is something you write once after a couple of tests, you won't notice. 

 

Disclaimer time: if you find yourself having to use local variables and value properties a lot, then you are probably just "programming as you go" and not planning out the application enough. Once you plan it out and use a reasonable design pattern, you will be writing to the terminals most of the time.

 

Capture.PNG

0 Kudos
Message 6 of 7
(2,728 Views)

Appreciate all the suggestions and feedback. Thanks guys!

0 Kudos
Message 7 of 7
(2,721 Views)