andfanilo / streamlit-drawable-canvas

Do you like Quick, Draw? Well what if you could train/predict doodles drawn inside Streamlit? Also draws lines, circles and boxes over background images for annotation.
https://drawable-canvas.streamlit.app/
MIT License
563 stars 85 forks source link

Center Align the widget. #27

Closed khanfarhan10 closed 3 years ago

khanfarhan10 commented 3 years ago

In case the canvas does not span the full screen, I want the tool to be center aligned.

andfanilo commented 3 years ago

Hey @khanfarhan10,

While I could position the canvas to the center, I think this is something that should be solved at Streamlit's level rather than for every component, so let me raise the issue at their level.

In the meantime you can cheat by using column layout to push the canvas a little to the right:

import streamlit as st
from streamlit_drawable_canvas import st_canvas

canvas_css = """
.stMarkdown {
    display: grid;
    place-items: center;
}
"""
st.markdown(f'<style>{canvas_css}</style>', unsafe_allow_html=True)  # to center title for reference

st.title("Center canvas")
col1, col2 = st.beta_columns((0.1,1))
with col2:
    st_canvas()
khanfarhan10 commented 3 years ago

Ahaaa using columns, right! Thanks!