How to refer to a particuler container when there are multiple containers?

Hi Guys,

I’m new to streamlit . I tried finding most suitable tags for my question. but idk if it’s correct or not.

I’m working on a project which requires to add multiple charts dynamically which can be used for comparison. I found out that containers can hold any widget,but I don’t see any parameters for st.container() that can be used to refer a specific container.

The functionality i wan’t to achieve is :

1. Delete a specific container.
Which will in turn delete the chart if user thinks it not necessary

Anyway i can achieve this ?

You could try something like this:

import streamlit as st
import numpy as np

c1, c2 = st.columns([1,1])
show_p1 = c1.checkbox('Show panel 1', True)
show_p2 = c2.checkbox('Show panel 2', True)

panel1 = c1.empty()
panel2 = c2.empty()

if show_p1:
  with panel1.container():
    st.bar_chart(np.random.randn(10, 3))
else:
  c1.write('Empty!')
  panel1 = st.empty()

if show_p2:
  with panel2.container():
    st.bar_chart(np.random.randn(10, 3))
else:
  c2.write('Empty!')
  panel2 = st.empty()



(Showing charts, not a map, but same idea.)

HTH,
Arvindra

1 Like

hi @asehmi

Thanks for the reply i think this will work for my need.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.