Is it possible to use st.write and st.code in one line? I’d like to provide some information with st.code, because I’d like to have to copy button. But i’d like to label the information because st.code has no label. The label I’'d like to print st.write.
This doesn’t work:
'hello', st.code("world")
I tried columns. But then the rows aren’t aligned.
Hi @feelancer21, how about you try something like this?
import streamlit as st
c1, c2, c3 = st.columns((1,4,9)) # 3rd col = blank for spacing
c1.write("") # vertical filler
c1.write('hello, ')
c2.code("world")
Cheers
Thanks, but the lines between the cols are not aligned in a row, if you duplicate it. Seems I have to put in a container.
You can duplicate manually (rows 1-3) or from within a loop (rows 4-6)
import streamlit as st
c1, c2, c3 = st.columns((1,4,9)) # 3rd col = blank for spacing
c1.write("") # vertical filler
c1.write('hello, ')
c2.code("world")
c1, c2, c3 = st.columns((1,4,9)) # 3rd col = blank for spacing
c1.caption("") # vertical filler
c1.write('hello, ')
c2.code("world")
c1, c2, c3 = st.columns((1,4,9)) # 3rd col = blank for spacing
c1.write("") # vertical filler
c1.write('hello, ')
c2.code("world")
for i in range(0,3):
c1, c2, c3 = st.columns((1,4,9)) # 3rd col = blank for spacing
c1.write("") # vertical filler
c1.write('hello, ')
c2.code("world")
Cheers
Yes, but there is no alignment
This works:
for _ in range(10):
with st.container():
c1, c2, c3 = st.columns((1,4,9)) # 3rd col = blank for spacing
c1.write("") # vertical filler
c1.write('hello')
c2.code("world")