Idea would be like
st.button(x = 100, y =200)
st.sidebar,button(x = 100, y =200)?
is it possible?
or any recommedation thanks
Idea would be like
st.button(x = 100, y =200)
st.sidebar,button(x = 100, y =200)?
is it possible?
or any recommedation thanks
Hi @apex_yu,
First I would like to say, welcome to the Streamlit community!!!
For your question, without knowing exactly what your trying to achieve (a minimum working example is encouraged when posting a question!) I would say Streamlit doesnβt have this function. The button only takes maximum of 2 arguments, one of which is the name you want to have on the button. Check out our documentation for more details. So you canβt pass in an x and y coordinate that corresponds to a position on your app.
However, there are ways to adjust the layout of your app, and to be able to put buttons and widgets in specific areas of the page (just not with pixel level precision). Here are some options you may want to try:
import streamlit as st
# to make your app take up all the available space in the browser window
# (not just a single column)
st.set_page_config(layout='wide')
st.title("Title of an app")
# you can create columns to better manage the flow of your page
# this command makes 3 columns of equal width
col1, col2, col3 = st.beta_columns(3)
# this will put a button in the middle column
with col2:
st.button("I am a button")
st.write("Now on to the other columns")
# this command will make 3 columns of unequal width
# first column is largest and 3x the size of the last,
# second column is 2x the size of the last
col4, col5, col6 = st.beta_columns([3,2,1])
# this will put a checkbox in the last column
col6.checkbox("I am a checkbox")
This looks like:
If you want to know more checkout the docs on laying out your app or this post on layout:
Happy Streamlit-ing!
Marisa
thanks you. I am using this new layout now,
however, the (Y co-coordndate or position ) cannot be organised
and i am assuming (for the row element its run according to python line of βrowβ code to execute,
And can it be applied to the sidebar part?
thanks
Sorry I donβt know what you mean by this
Yes it can:
side_1, side_2 = st.sidebar.beta_columns(2)
with side_1:
st.write('column 1')
st.checkbox('checkbox in sidebar')
with side_2:
st.write('column 2')
gives:
BUT:
The size of the sidebar does not change, if you try putting to many columns in it will be come crowded and confusing! I personally would only put columns in your sidebar if absolutely necessary and only ever put 2 columns in.
Happy Streamlit-ing!
Marisa
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.
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.
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.
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.