Spaces:
Running
Running
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) | |