streamlit4c / app.py
seawolf2357's picture
Update app.py
d92242c verified
raw
history blame
2.51 kB
import streamlit as st
# νŽ˜μ΄μ§€ μ„€μ •
st.set_page_config(page_title="ViDraft", layout="wide")
# μ„Έμ…˜ μƒνƒœ μ΄ˆκΈ°ν™”
if 'selected_menu' not in st.session_state or 'selected_sub_menu' not in st.session_state:
st.session_state['selected_menu'] = 'Home'
st.session_state['selected_sub_menu'] = None
# 'Home' λ²„νŠΌ 클릭 μ‹œ μ„Έμ…˜ μƒνƒœλ₯Ό 'Home'으둜 μ„€μ •ν•˜λŠ” ν•¨μˆ˜
def set_home():
st.session_state['selected_menu'] = 'Home'
st.session_state['selected_sub_menu'] = None
# μ‚¬μ΄λ“œλ°” 타이틀 μ„€μ • 및 'Home' λ²„νŠΌ μΆ”κ°€
st.sidebar.title("ViDraft")
st.sidebar.button('Home', on_click=set_home)
# 메뉴 ν•­λͺ©κ³Ό ν•˜μœ„ ν•­λͺ© μ •μ˜
menus = {
"Free Stock": ["Template Video", "Template Image", "Search Video", "Search Image"],
"Image": ["Generation", "Face ID", "Inpainting", "Remove Background", "Studio"],
"Video": ["Generation", "Talking Face", "Remove Background", "Studio"],
"Sound": ["Video SFX", "Video Music", "TTS(Voice)", "Voice Clone", "Image SFX", "Image Music"],
"Scripts": ["Script"]
}
# 각 메뉴별 ν•˜λΆ€ 메뉴λ₯Ό 펼침
for menu_name, sub_menus in menus.items():
if menu_name != 'Home': # 'Home'은 ν•˜μœ„ 메뉴가 μ—†μœΌλ―€λ‘œ μ œμ™Έ
with st.sidebar.expander(menu_name):
# ν•˜λΆ€ 메뉴λ₯Ό 선택할 수 μžˆλŠ” selectbox 생성
selected = st.selectbox(f"Select {menu_name} option", [""] + sub_menus, key=menu_name, on_change=set_home)
if selected:
st.session_state['selected_menu'] = menu_name
st.session_state['selected_sub_menu'] = selected
# μ„ νƒλœ 메뉴와 ν•˜λΆ€ 메뉴에 λ”°λ₯Έ λ‚΄μš© ν‘œμ‹œ
if st.session_state['selected_menu'] == 'Home':
st.title("Welcome to ViDraft")
st.write("This is the Home page. Select an option from the sidebar to get started.")
else:
st.subheader(f"{st.session_state['selected_menu']} > {st.session_state['selected_sub_menu']}")
# 여기에 μ„ νƒλœ 메뉴에 λ”°λ₯Έ μ½˜ν…μΈ  ν‘œμ‹œ 둜직 μΆ”κ°€
# λΉ„λ””μ˜€ 파일 경둜 μ„€μ •
video_files = ["ex1.mp4", "ex2.mp4", "ex3.mp4", "ex4.mp4", "ex5.mp4", "ex6.mp4", "ex7.mp4","ex8.mp4", "ex9.mp4", "ex10.mp4", "ex11.mp4", "ex12.mp4", "ex13.mp4", "ex14.mp4","ex15.mp4", "ex16.mp4", "ex17.mp4", "ex18.mp4"]
# 가러리 ν˜•νƒœλ‘œ λΉ„λ””μ˜€ ν‘œμ‹œ
cols = st.columns(2) # 2개의 μ—΄λ‘œ λ„“κ²Œ 배치
for index, video_file in enumerate(video_files):
with cols[index % 2]:
st.video(video_file)