Team1-TU-tech / login

0 stars 0 forks source link

[Streamlit] To fix this error, please pass a unique `key` argument to `st.text_input`. #14

Open hamsunwoo opened 1 day ago

hamsunwoo commented 1 day ago

When a widget is created, it's assigned an internal key based on its structure. Multiple widgets with an identical structure will result in the same internal key, which causes this error.

To fix this error, please pass a unique key argument to st.text_input.

hamsunwoo commented 23 hours ago

저의 코드입니다.

# 로그인 화면
def login_screen():
    st.title("로그인")
    userid = st.text_input("아이디를 입력해주세요.")
    password = st.text_input("비밀번호를 입력해주세요.", type="password")
    if st.button("Login"):
        login(userid, password)
hamsunwoo commented 23 hours ago

해당 오류는 login_screen 함수를 두번 호출해서 생겼던 오류였으므로 해결하였습니다.

def login_screen():
    st.title("로그인")
    userid = st.text_input("아이디를 입력해주세요.", key="userid_input_1")
    password = st.text_input("비밀번호를 입력해주세요.", type="password", key="password_input_1")

    if st.button("Login"):
        if userid and password:  # 입력된 값이 있는지 확인
            login(userid, password)
        else:
            st.error("아이디와 비밀번호를 입력해주세요.")