LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create and resize button in a running VI

Hi,

 is it possible to create and resize a button in a running vi's front panel?
I would like for example to place a square button where I press mouse down and then, if I drag left and right borders, resize it.
I've done something similar in the past using images, but this time I need buttons to be single objects I can move in a second time

0 Kudos
Message 1 of 21
(2,858 Views)

Ciao,

sadly, you can't create controls in a running vi. Not even resize it.

You can only unhide and move existing controls.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 21
(2,852 Views)

Hi gepponline,

 


@gepponline wrote:

is it possible to create … a button in a running vi's front panel?


No.

You cannot edit a VI while it is running. (Creating a new frontpanel object means editing the VI!)

 


@gepponline wrote:

is it possible to … resize a button in a running vi's front panel?


Yes, sure!


@gepponline wrote:

I would like for example to place a square button … and then, if I drag left and right borders, resize it.


Learn about panes and splitters.

Then place a button in a pane with surrounding splitter bars and have the button fit to (or: adapt with) the pane…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 21
(2,848 Views)
I know resize is possible, maybe a little tricky to do dragging the border, but possible. Is the creation of the object that I was hoping it had been implemented somehow over the years:(
0 Kudos
Message 4 of 21
(2,844 Views)
It's not clear what you mean with "place a button with surrounding bars and have the button fit to the pane"
My will is to have something similar to a timeline in a videoeditor software.
I should be able to place some (they can be several) square objects in a row, move them and resize them according to my needs
0 Kudos
Message 5 of 21
(2,840 Views)

Hi gepponline,

 


@gepponline wrote:
It's not clear what you mean with "place a button with surrounding bars and have the button fit to the pane"

As I wrote: learn about panes and splitter bars.

You use splitter bars to subdivide a panel into several panes. You can select several resizing options for each pane and splitter bar…

 


@gepponline wrote:
My will is to have something similar to a timeline in a videoeditor software.
I should be able to place some (they can be several) square objects in a row, move them and resize them according to my needs

You didn't say so in your first message.

What about using a 2DPictureIndicator to draw all your "square objects" as needed?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 21
(2,831 Views)

@gepponline  ha scritto:
I know resize is possible, maybe a little tricky to do dragging the border, but possible. Is the creation of the object that I was hoping it had been implemented somehow over the years:(

I never tried the pane-splitters technique, sure it does not seem to be very handy, especially for multiple objects...

In one of our applications we tried to mimic the creation of specific types of indicators by placing a single indicator in a vi (with no code) and running the vi into a subpanel; the subpanel area is resized to the actual size of the contained indicator, so it looks like a simple indicator itself. It works, but it's very tricky too. First, you can only interact with the indicators via references and dynamic events. Second, you can only create a fixed number of objects: the number of subpanels you put on the main FP.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 7 of 21
(2,815 Views)
I've already done it in the past, the problem is after I place an object in the picture, the object become part of the picture and hard to identify for following modifications 😞
Still not clear about panes. I already use panes in some projects..but maybe it's my faut due to my description in the main post.
Thinking about it...I'm working on a GANTT application using table..maybe it can be useful 🙂
0 Kudos
Message 8 of 21
(2,810 Views)

I'm sure you realize that a "button" is more than just a "picture of something you can "press with a mouse", in that LabVIEW also creates "code that does something when you click the object".  In a running LabVIEW program, it is "challenging" (to say the least) to create code "on the fly" that reacts when you click a specified "object".

 

But maybe you can do it.  I'm just "imagining" this off the top of my head, so don't yell too loudly at me if I bungle something.  Consider the Event Structure.  It has a "Pane" Event that includes a "Mouse Down" (and "Mouse Down?") Event, which can return the coordinates of the Mouse when clicked.  You can create a "Picture of a Button" and place it on your Pane, and use the Mouse Down Event to compute if the User clicked on your Button.  If so, you can do whatever is appropriate (including changing the appearance of the Button -- it's only a Picture, after all).

 

Of course, if all you want are particular Controls that appear at fixed places at certain times in your code, there's an easier way, and even lets you "move" the Control (by trickery).  Simply create the Control(s) where you want them to appear (and if you want them to "appear to move", create two Controls, one in each position).  Before your program starts, set the Visibility property of all the Controls you don't want to see to False.

 

I used this once when I had a Green "Go" button that I wanted the User to press when a Run should be started.  Once the Run was started, I made "Go" invisible and made "Pause", placed in exactly the same spot as "Go" (but with a different "working Color, Yellow, as I recall) become Visible.  When Pause was pressed, it got replaced by "Continue" (also colored Green) using the same process.  One nice side-effect is that there were three different Event Structures, so the code to "figure out what to do" was very simple.

 

Bob Schor

Message 9 of 21
(2,797 Views)
Yes, I don't need a button at all but whatever object that allow me to identify if I'm acting on it with my mouse using event case.
But I can't know how many object I will need.
Of course I could create 500 hundres object and then make them appear and resize when I want, but I'm pretty sure the second after I will decide to create 500 object, I will need 501 of them and If I decide 1000, 1001 will be needed 😞
0 Kudos
Message 10 of 21
(2,787 Views)