Hi there! I am attaching an image for reference showing that I am trying to create multiple popovers based on data. But as you can see there no uniformity in them. I want to customize them have uniform size and background color. How can I do that ?? Please help.
There are too many elements in a single row, in order to have it look visually better, the popover elements would need more width space.
A possible solution: I’d suggest to create a for loop that dynamically assigns each of the popover elements to a specific column.
For example, say you want to create 5 columns and you have 10 elements, then you’d create a for loop that dynamically assigns element 1 to column 1 of row 1, element 2 to column 2 of row 1, …, element 9 to column 4 of row 2, and element 10 to column 5 of row 2.
Thus, you’ll probably need 2 nested for loops where the first would iterate through the row and the second one would iterate through the columns.
Thank you for your response @dataprofessor . Actually, I have done the same.
counter = 1
for row in range(rows_required):
keyword_containers = st.container()
with keyword_containers:
if counter > total_keys:
break
columns = st.columns(10)
index = 0
for key,val in keys_count_desc.copy().items():
with columns[index]:
st.button(f"{key} : {val}",key=counter, help="Click to show the data!", on_click=keyword_records, kwargs={"keyword":key}, use_container_width=True)
counter+=1
index+=1
keys_count_desc.pop(key)
if index>9:
break
In the above code, I have replaced st.popover with st.button but the purpose is same, i.e., to display data. But the labels that these buttons/popover are having could be too long to be inside that container, sometimes. That’s why I was looking for fixed-sized(width-hight) buttons or popover tricks so that it could look better on the dashboard.
Also please suggest, how we customize
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.