How do I set visibility of a panel from script?

I want a button to kind of turn on a panel and turn it off, but there don't seem to be a "setProp" method in the documentation

You need to use the custom variable syntax: wrting
VAR{show, true}
in the panel's visible property will create a custom variable named show with default value true, you'll be able to change its value from the button's script like so:

setVar('panel_id', 'show', value === getProp(this, 'on'))

(There's no setProp function)

1 Like

Thx! I always thought setVar can only affect custom variable(I thought it means user created) and won't affect the properties, turns out the visible property have a "custom variable" named show :thinking:

Hi,

just a json file to illustrate the solution proposed by jean-emmanuel
button-to-show-hide-a-panel.json (6.2 KB)

Custom variables can be used in any properties, there is no predefined variable name assigned to a particular property, "show" is just an example here, you can give it any name you want.

Of course , don't understand why you add this warning

Sorry my message was a reply to Barry's post.

Pas de souci

thx for the tip! I understand how custom variables work now~

thank you! this is super clear :grin: