# Making a Component Invisible if the relevant tag is True and Visible if the tag is False

**URL:** <https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [October 6, 2022, 1:31pm UTC](https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900 "2022-10-06T13:31:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_Friedman](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@Brandon\_Friedman](https://forum.inductiveautomation.com/u/Brandon_Friedman)\
**Post date:** [October 6, 2022, 1:31pm UTC](https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900/1 "2022-10-06T13:31:28Z")

</div>

Hey there everybody, first of al thank you everyone who helped out with my first question and helped me solve that issue. I have another one for everyone now. So I am trying to make a button component invisible in Vision based on the value of a Boolean tag. What I need for it to do is to be visible when the associated tag is False and invisible when it is True. I tried to script it out, but alas I am still very very new to scripting, and can't quite figure it out. The following is what I scripted in a basic form.

```auto
"""Alpha is the associated Boolean Tag."""
"""Bravo is the Visibility property of the button."""
if Alpha == True:
    Bravo == False
if Alpha == False:
    Bravo == True

```

Is there an easier way to do this, or have I missed something due to my inexperience in scripting?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 6, 2022, 1:36pm UTC](https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900/2 "2022-10-06T13:36:14Z")

</div>

There is an easier way, just invert the tag value.

If you can use an expression, then use an expression. Scripting is a powerful tool, but it isn't always the best tool to use, and it shouldn't be the first choice.

Use an expression binding:

```nohighlight
!{your tag path}

```

To do this in scripting you would do something like:

```python
Brovo = not Alpha

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 6, 2022, 2:18pm UTC](https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900/3 "2022-10-06T14:18:24Z")

</div>

Also note that `==` does not perform assignment. If for some reason you couldn't use @lrose 's solution, you would have to edit your script at least like so:

```auto
if Alpha == True:
    Bravo = False
if Alpha == False:
    Bravo = True

```

Even better would be:

```auto
if Alpha:
    Bravo = False
else:
    Bravo = True

```

---

<div class="post-metadata">

**Author:** ![Brandon\_Friedman](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@Brandon\_Friedman](https://forum.inductiveautomation.com/u/Brandon_Friedman)\
**Post date:** [October 6, 2022, 2:33pm UTC](https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900/4 "2022-10-06T14:33:42Z")

</div>

Thank you, I'll apply it to the same button for another unit and when I can connect to the OPCUA server when our test bench is free.

---

<div class="post-metadata">

**Author:** ![Brandon\_Friedman](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@Brandon\_Friedman](https://forum.inductiveautomation.com/u/Brandon_Friedman)\
**Post date:** [October 6, 2022, 2:43pm UTC](https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900/5 "2022-10-06T14:43:05Z")

</div>

I have your solution @lrose attached to a button for one of two units that are the same design in everything. When the OPCUA server on our test bench is open, I'll test it out.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 6, 2022, 2:56pm UTC](https://forum.inductiveautomation.com/t/making-a-component-invisible-if-the-relevant-tag-is-true-and-visible-if-the-tag-is-false/64900/6 "2022-10-06T14:56:41Z")

</div>

> [@pturmel](#):
>
> ```auto
> if Alpha:
> Bravo = False
> 
> ```

This made me remember [a comic](https://www.reddit.com/r/ProgrammerHumor/comments/4x26u3/this_is_why_code_reviews_are_a_good_thing/?utm_source=share&utm_medium=android_app&utm_name=androidcss&utm_term=1&utm_content=share_button) that I read some time ago that graphically illustrates why using bools without `==` is typically preferred.
