LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Set TRUE/FALSE Image of a boolean control automatically using spripting ?!

Hello Scripting Community,

i try to use scripting to generate Buttons with Images for True and False Case automatically.

Details:

I would like to generate a button library with a lot of buttons with same size and behaviour.

In fact it's a cluster of three booleans, one over each other with transparent images on it.

These booleans are:

- the symbol itself

- the actual state (true/false two (partly) transparent images)

- a mouse-over boolean showing a (partly) transparent image

Now i'm looking for a possibility to automatically set the image of the "symbol-boolean".

Does anyone know if it's possible to set this images using scripting ?

I tried a workaround an used a picture control instead of the boolean ( I don't need it's function as a boolean, it just shows the symbol).

Everything worked fine an i created a huge number of (stricttypedef) controls.

But i then noticed, that the picture control can't handle transparencies with gradients. It only handles 100% or 0% transparency.

So the nice symbols i want to use look awful in the picture control.

screenshot.jpg

Left my button with picturecontrol, right the original symbol i would like to import.

If it's not possible to set the image on a boolean.....

Is it possible to programmatically set a image as a decoration in a cluster?

Has anyone an idea how to get these images into a cluster?

Thanks in advance,

Rainer

0 Kudos
Message 1 of 23
(20,310 Views)

Hi Rainer,

unfortunately, it's not possible at the moment. I investigated this a few months back and got this answer which was subsequently backed by other answers in other threads. I have not heard NI infirm this information yet.

At the moment, I think the only way to accelerate your process is to programmatically generate all the images you need for each of your buttons' states in a folder. You'd then have to copy the images manually in the control editor. I'm working on something similar with the Nuvola icons. That's quite a long endeavour, so if you find any tips on how to accelerate this process, your thoughts are welcome.

GCentral ChampionCLA
0 Kudos
Message 2 of 23
(7,664 Views)

Cross-post to: http://lavag.org/topic/11521-programmatically-changing-image-within-control/

I found the way how to change image on boolean button without using control editor. Essentially you have to to manually insert a png as button image and then replace it with another png programmatically inside .ctl file. The only condition is that initial png file has to have greater filesize than new one. If you want to make a lot of buttons just create first one using biggest PNG (by file size not dimensions). Technically it should be possible to replace any image inside a control with this method.
As .ctl file looks exactly like macintosh resource fork, it should be also possible to omit the limitation of smaller size, by updating respective offsets within a file, however I failed with first trials (not many).
Example attached - LV8.2

Download All
0 Kudos
Message 3 of 23
(7,664 Views)

vugie wrote:

As .ctl file looks exactly like macintosh resource fork, it should be also possible to omit the limitation of smaller size, by updating respective offsets within a file, however I failed with first trials (not many).

Example attached - LV8.2

The LabVIEW resource file format while very similar to the Macintosh resource file format, is not EXACTLY the same. For your purpose it might be similar enough to be able to figure out the internal structure, but replacing information inside that file format would in fact require quite a bit of resource file handling code to be always working properly. Replacing resources properly basically means rewriting the entire file with the original data minus the replaced part and the new data in it.

The good news is that LabVIEW already has that code and working well too, and that the LabVIEW kernel actually exports those functions as C functions. The bad news is that there is officially no documentation about this API, and the VI libraries from NI that I have seen so far accessing that API where all password locked and part of a LabVIEW library, so very hard to use in different projects.

I had a go at those APIs quite some time ago, and will see if I can dig up some code and most importantly some examples.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 23
(7,664 Views)

rolfk wrote:

The good news is that LabVIEW already has that code and working well too, and that the LabVIEW kernel actually exports those functions as C functions. The bad news is that there is officially no documentation about this API, and the VI libraries from NI that I have seen so far accessing that API where all password locked and part of a LabVIEW library, so very hard to use in different projects.

I had a go at those APIs quite some time ago, and will see if I can dig up some code and most importantly some examples.

Do you mean these functions from LabVIEW.exe which contains "Archive" or "Resource" in their names?

Judgeing by this specification LV file structure is really close to resource fork.

0 Kudos
Message 5 of 23
(7,664 Views)

vugie wrote:

rolfk wrote:

The good news is that LabVIEW already has that code and working well too, and that the LabVIEW kernel actually exports those functions as C functions. The bad news is that there is officially no documentation about this API, and the VI libraries from NI that I have seen so far accessing that API where all password locked and part of a LabVIEW library, so very hard to use in different projects.

I had a go at those APIs quite some time ago, and will see if I can dig up some code and most importantly some examples.

Do you mean these functions from LabVIEW.exe which contains "Archive" or "Resource" in their names?

Judgeing by this specification LV file structure is really close to resource fork.

Archive functions are specifically for LLBs only. The functions I mean all start with an R such as ROpenFile.

And yes the LabVIEW resource file format is close the the Macintosh resource fork format, but not exactly the same.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 23
(7,664 Views)

Hello all,

after beeing some days off I'm back

Thank you for your replies so far !

@normandinf:

Very sad, that NI doesn't see the importance of this feauture.

Doing this manually is no option for me.

@vugie:

Great idea to do this on file basis. I'll give it a try.

@Rolf Kalbermatter:

Are there any questions you don't have an answer to? 

I would appreciate if you you are able to find these examples.


It would be greate to edit these LabVIEW resource files with NI build in methods. (Even if it's hidden inside)

Meanwhile i'll try to remote control the "control editor" with an AutoIt script.

Thanks to all,


Rainer

0 Kudos
Message 7 of 23
(7,664 Views)

I made a small VI for doing this. It uses LV internal API, Rolf mentioned.

0 Kudos
Message 8 of 23
(7,664 Views)

Hi Rainer,

I think NI does see the importance of this, but it's not as high on their list as we'd wish. The fact is that most LabVIEW programmers will be quite happy with the default controls since for them, LabVIEW is just a quick and efficient way to put code that work together... not a UI building tool. As long as it works, the looks is secondary.

Hopefully, with more and more people considering LabVIEW as a truly general programming language, that's about to change. The simple fact that there are groups like this one means the thrust is in the right direction...

And I agree, doing this manually is a no-no...

GCentral ChampionCLA
0 Kudos
Message 9 of 23
(7,664 Views)

Hello all,

RESPECT !!

How do you find these internal functions?

Now I'm able to create the buttons i want to create without touching them !

I changed your VI to my needs. (See attachment.)

Thank you all very much !!

BTW, are there any informations about the internal resource structure one can use to change the look?

I never saw a control you (vugie) used for the constant inside your vi .

It loos cool with the image attached to the left an shifting it when pressed.

Thanks again, best regards,

Rainer

P.S.: Where can i give Kudos here?

P.P.S.: Is it "on the button" or "in the button"? I'll never learn ....

0 Kudos
Message 10 of 23
(7,664 Views)