question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Displaying image at the same place

See original GitHub issue

Summary

Hi all, I try to make when the st.image(new_image) is called, the place where it display is the same as the st.image(old_image). In other word, the new_image replace the old_image (only display one image) instead of display both the new_image and old_image.

Steps to reproduce

I have the following function:

def main(): st.image(old_image) if st.checkbox("New Layer"): st.image(new_image)

When I click the “checkbox”, it displays a new image underneath the old_image. However, I want to display “new_image” and not “old_image” anymore.

I’d appreciate any suggestions!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

5reactions
asw-v4commented, Oct 23, 2020

You should create an empty placeholder instead of an image:

imageLocation = st.empty()

Then you can edit the content in this same location however you want (Even change it from an image to a graph, video or anything else!)

imageLocation = st.empty()
.
.
.
imageLocation.image(old_image)
if st.checkbox('New Layer'):
    imageLocation.image(new_image)

3reactions
Linshu107commented, Oct 22, 2019

Awesome, thank you very much! I want to make a quick update just for future reference. imageLocation = st.empty() . . imageLocation.image(old_image) # no need extra “st.”

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I position one image on top of another in HTML?
The easy way to do it is to use background-image then just put an <img> in that element ...
Read more >
How To Align Images Side By Side - W3Schools
How To Place Images Side by Side. Step 1) Add HTML: ... Step 2) Add CSS: How to create side-by-side images with the...
Read more >
Method for making image stay in same position? - HTML & CSS
The idea here is that by putting them together in the element, it will position the bubble in relation to its container, keeping...
Read more >
How to Align and Float Images with CSS | Web Design
Aligning images will only position the image left, right, or center with the text ... This is good for displaying images like a...
Read more >
What is the process for placing two images next to each other ...
Two images inside the same container will normally display as inline unless the combined width is greater than the container or something in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found