Clickable button that shows/hides a picture

How do you make a button show/hide pictures (change functionality when clicked)?

Hello,

Please read the guidelines on how to ask a good question:

You will likely want to toggle the visibility property to show/hide an image based on the click event of a button.

In the design I uploaded a picture. I would like to make the image appear and disappear with a button click. I found the properties of an image, self.house.visible = True. I also found the image events of
show() and hide() on the screen. I uncheck the image visible box and put in the button function self.house.visible = True, but nothing happens. self.house.show() does not work either.

The documentation provides no further details, that I can find.

As the tips above for asking a good question suggest, it would be helpful to share a small example bit of code so that we can see more closely what is going on.

You can even share a clone link (click the gear icon to do so).

You will want to toggle the visibility property likely, but without more actual code blocks/a clone, we can’t tell exactly what is going on.

If I had to guess, the click event of the button has not been “tied” to the function in code that toggles visibility. This can be done in the IDE. I’m just compleley guessing at the issue though.

Please search for “events” in the documentation to see how they work.

Please be more clear by sharing more code and/or a clone.

Below is an attempt at getting the image to appear. The name of the image is “house.” Visible is unchecked, so the image is not visible when I run. Below is pretty much all I could find in your documents and API reference about getting an image to be visible, no code samples of it. Not a lot to go on.

image

image

Thank you for sharing more complete details.

For one I can see that you need to use “True” instead of “true”. That is, in Python boolean operators are capitalized.

Thanks, it works, I can’t believe I missed the lower case in True!