LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically Resize Front Panel Objects Based on Content

Hi everyone,
I wonder if there's a dynamic way to resize front panel objects—such as string indicators—based on their content. For example, I'd like an indicator to automatically adjust its width or height depending on the length of the text it displays, without having to set fixed dimensions manually.
Has anyone implemented something similar or found a workaround for this? I'm working on a UI that needs to adapt to varying data sizes, and I'm trying to keep the interface clean and readable without wasting space.
Any suggestions or examples would be greatly appreciated!
Thanks in advance,
Fabio

 

0 Kudos
Message 1 of 6
(440 Views)

Sure, use Get Text Rect.vi

Forum.png

 

Basjong53_1-1761297810017.gif

 

Message 2 of 6
(422 Views)

Hi Fabio,

 


@fabio.int wrote:

For example, I'd like an indicator to automatically adjust its width or height depending on the length of the text it displays, without having to set fixed dimensions manually.


You can determine the (pixel) size of your text by using the 2DPicture functions.

Using this information you can then adjust the size of the string indicator using its property nodes...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(419 Views)

Thanks for your reply!

I realize I didn't explain myself clearly earlier. What I'm actually trying to do is adjust the font size of a string indicator dynamically, so that the text fits within the fixed width of my front panel. In other words, instead of resizing the indicator itself, I'd like the font size to adapt based on the length of the content.

Has anyone tried something similar or found a way to achieve this?

0 Kudos
Message 4 of 6
(403 Views)

Hi Fabio,

 


@fabio.int wrote:

What I'm actually trying to do is adjust the font size of a string indicator dynamically, so that the text fits within the fixed width of my front panel.


You basically do the same steps:

  1. Determine the pixel size of your text using the very same 2DPicture function
  2. When the size fits: goto step 5
  3. Change the font size for the pixel size calculation (increment/decrement)
  4. Goto step 1
  5. Display the text in the string indicator and set the font size used in step 1

@fabio.int wrote:

I wonder if there's a dynamic way to resize front panel objects—such as string indicators—based on their content.

 

I realize I didn't explain myself clearly earlier.


Yes.

In your first message you wanted to change the object size depending on the content.

Now you want to change the content size for a fixed object size…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(372 Views)

Consider leaving the font size alone for accessibility reasons and allow the user to scroll through the string indicator.

Readable, but incomplete:

dsbNI_0-1761323323975.png

 

Not readable for most audiences, still incomplete

dsbNI_3-1761323725540.png

 

 

Readable, incomplete:

dsbNI_2-1761323637303.png

 

Generally, I think your UI will be better if you decide how much space you can allocate for each control and indicator, keep a consistent font size, and let the user scroll through text where there is more information than fits in the allotted indicator size.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 6 of 6
(328 Views)