title: PySimpleGUI - Login Authenticator
body: <p>I'm having trouble getting the login authenticator to work. Everything works fine except the login() function. The other two functions progress_bar() and create_account() are running without a problem. I keep getting a <strong>KeyError: '-username-'</strong> message. I've tried everything, even not using functions, and still. I can't find the issue. Anyone? @MacItaly</p>
  <pre><code>import PySimpleGUI as sg
  
  #PROGRESS BAR
  def progress_bar():
      sg.theme('LightBlue2')
      layout = [[sg.Text('Creating your account...')],
              [sg.ProgressBar(1000, orientation='h', size=(20, 20), key='progbar')],
              [sg.Cancel()]]
  
      window = sg.Window('Working...', layout)
      for i in range(1000):
          event, values = window.read(timeout=1)
          if event == 'Cancel' or event == sg.WIN_CLOSED:
              break
          window['progbar'].update_bar(i + 1)
      window.close()
  
  
  def create_account():
      sg.theme('LightBlue2')
      layout = [[sg.Text(&quot;Sign Up&quot;, size =(15, 1), font=40, justification='c')],
               [sg.Text(&quot;E-mail&quot;, size =(15, 1),font=16), sg.InputText(key='-email-', font=16)],
               [sg.Text(&quot;Re-enter E-mail&quot;, size =(15, 1), font=16), sg.InputText(key='-remail-', font=16)],
               [sg.Text(&quot;Create Username&quot;, size =(15, 1), font=16), sg.InputText(key='-username-', font=16)],
               [sg.Text(&quot;Create Password&quot;, size =(15, 1), font=16), sg.InputText(key='-password-', font=16, password_char='*')],
               [sg.Button(&quot;Submit&quot;), sg.Button(&quot;Cancel&quot;)]]
  
      window = sg.Window(&quot;Sign Up&quot;, layout)
  
      
      while True:
          event,values = window.read()
          if event == 'Cancel' or event == sg.WIN_CLOSED:
              break
          else:
              if event == &quot;Submit&quot;:
                  if values['-email-'] != values['-remail-']:
                      sg.popup_error(&quot;Error&quot;, font=16)
                      continue
                  elif values['-email-'] == values['-remail-']:
                      progress_bar()
                      break
      window.close()
  create_account()
  
  
  def login():
      sg.theme(&quot;LightBlue2&quot;)
      layout = [[sg.Text(&quot;Log In&quot;, size =(15, 1), font=40)],
              [sg.Text(&quot;Username&quot;, size =(15, 1), font=16),sg.InputText(key='-usrnm-', font=16)],
              [sg.Text(&quot;Password&quot;, size =(15, 1), font=16),sg.InputText(key='-pwd-', password_char='*', font=16)],
              [sg.Button('Ok'),sg.Button('Cancel')]]
  
      window = sg.Window(&quot;Log In&quot;, layout)
  
      while True:
          event,values = window.read()
          if event == &quot;Cancel&quot; or event == sg.WIN_CLOSED:
              break
          else:
              if event == &quot;Ok&quot;:
                  if values['-usrnm-'] == values['-username-'] and values['-pwd-'] == values['-password-']:
                      sg.popup(&quot;Welcome!&quot;)
                      break
                  elif values['-usrnm-'] != values['-username-'] and values['-pwd-'] != values['-password-']:
                      sg.popup(&quot;Invalid login. Try again&quot;)
  
      window.close()
  login()
  </code></pre>