Python/Streamlit

Streamlit) ์›นํŽ˜์ด์ง€์—์„œ ์œ ์ €์—๊ฒŒ ์ˆซ์ž, ๋ฌธ์ž, ์‹œ๊ฐ„, ์ƒ‰ ์ž…๋ ฅ ๋ฐ›๊ธฐ

567Rabbit 2024. 4. 26. 17:34
#์œ ์ €ํ•œํ…Œ ์ˆซ์ž, ๋ฌธ์ž, ์‹œ๊ฐ„, ์ƒ‰์„ ์ž…๋ ฅ๋ฐ›๋Š” ๋ฐฉ๋ฒ•


import streamlit as st

def main() :
    #1. ์ด๋ฆ„ ์ž…๋ ฅ๋ฐ›๊ธฐ
    name = st.text_input('์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”!')
    
    if name :
        st.text( name + "๋‹˜ ์•ˆ๋…•ํ•˜์„ธ์š”")
    else :
        st.text('')
        
    #2. ์ž…๋ ฅ ๊ธ€์ž ๊ฐฏ์ˆ˜ ์ œํ•œ
    address = st.text_input('์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”', max_chars=10)
    st.text(address)

    #3. ์—ฌ๋Ÿฌ ํ–‰์„ ์ž…๋ ฅ๊ฐ€๋Šฅํ† ๋ก
    message = st.text_area('๋ฉ”์„ธ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”', height=3)
    st.text(message)
    
    #4. ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ (12๊ธ€์ž๊นŒ์ง€)
    password = st.text_input('๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”', max_chars=12, type='password')
    st.text(password)
    
    #5. ์ •์ˆ˜ ์ž…๋ ฅํ•˜๋Š” ๋ฐฉ๋ฒ•
    st.number_input('์ˆซ์ž ์ž…๋ ฅํ•˜์„ธ์š”', -50, 100, step=10)
    
    #6. ์‹ค์ˆ˜ ์ž…๋ ฅํ•˜๋Š” ๋ฐฉ๋ฒ•
    st.number_input('์ˆซ์ž ์ž…๋ ฅํ•˜์„ธ์š”', -5.3, 10.8, step=0.5)
    
    #7. ๋‚ ์งœ ์ž…๋ ฅํ•˜๋Š” ๋ฐฉ๋ฒ•
    my_date = st.date_input('์•ฝ์† ๋‚ ์งœ ์„ ํƒ')
    print(my_date)
    st.write(my_date)
    print( type(my_date) )
    
    #8. ์š”์ผ ์ฐ๊ธฐ
    st.text( my_date.weekday())
    st.text( my_date.strftime('%A'))
    
    #9. ์‹œ๊ฐ„ ์ž…๋ ฅ๋ฐ›๋Š” ๋ฐฉ๋ฒ•
    my_time = st.time_input('์‹œ๊ฐ„์„ ํƒ')
    st.write(my_time)
    st.write(my_time.strftime('%H:%M'))
    
    #10. ์ƒ‰๊น” ์ž…๋ ฅ ๋ฐ›๋Š” ๋ฐฉ๋ฒ•
    color = st.color_picker('์ƒ‰์„ ์„ ํƒํ•˜์„ธ์š”')
    st.write(color)
    
if __name__ == '__main__' :
    main()