i was wondering what this error meant.
it seems to be something about the key, but if i change it it will say the is one with that key
(dont tell me its a coincidence, i tried many things :))
i was wondering what this error meant.
it seems to be something about the key, but if i change it it will say the is one with that key
hi henosBot,
This is probably because you are trying to make several text_inputs with the same label, in this case the label βUser IDβ. Is the statement user_id = id.text_input("User ID")
in a loop by any chance? If you only need one user input, you need to move it out of this loop.
If you need multiple inputs with the same label, you need to specify a βkeyβ for each input, an example could be
for i in range(3):
user_id = st.text_input("User ID", key=i)
although in many cases you would want to change the label instead.
this is my code:
import streamlit as st
import tools
import time
st.title('henos Roll Taking system')
markdown = st.empty()
markdown.markdown(tools.viewBeforeLogin)
id = st.empty()
passw = st.empty()
button = st.empty()
loggedin = False
while not loggedin:
user_id = id.text_input('User ID')
user_pass = passw.text_input('Password')
login = button.button('Login')
if login:
with st.spinner('Logging in ...'):
time.sleep(0.5)
tf, reason = tools.auth(user_id, user_pass)
if tf is False and reason == 'id':
incor = st.error('I could not find a user with that id')
try_again = button.button('Try again')
if try_again:
incor.empty()
continue
elif tf is False and reason == 'pass':
incor = st.error('Incorrect Password')
try_again = button.button('Try again')
if try_again:
incor.empty()
continue
else:
id.empty()
passw.empty()
button.empty()
markdown.empty()
loggedin = True
success = st.empty()
success.success('Logged in successfully')
time.sleep(2)
success.empty()
markdown.markdown(tools.viewAfterLogin)
mark = st.empty()
ctrl = st.empty()
markb = mark.button('Mark Roll')
ctrlb = ctrl.button('Control Panel')
Hi henosBot,
I think a good first step would be to replace the while statement with an if statement, and then make use of st.stop()
to make sure the user does not go further unless logged in.
You will likely also need to use the session state βhackβ to persist the login - I would recommend you search around the forum for examples on session state and authentication.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.