title: How can I make PySimpleGui read my input and update my window?
body: <p>I am not sure if this has been answered before, sorry for a duplicate if it was, but I couldn't find it anywhere clearly.</p>
  <p>I am making a GUI for my simple AIML chatbot (entertainment purposes mostly)
  and I found PySimpleGui. I read the whole documents of it and been trying to use their code, implementing it into my own small code I got from a tutorial.</p>
  <p>Originally:</p>
  <pre><code>
  kernel = aiml.Kernel()
  kernel.learn(&quot;std-startup.xml&quot;)
  kernel.respond(&quot;load aiml b&quot;)
  
  while True:
      input_text = input(&quot;You: &quot;)
      response = kernel.respond(input_text)
      print(&quot;Csigusz Foxoup (bot): &quot;+response)
  
  </code></pre>
  <p>I got this code working, all good (Thanks Misbah)</p>
  <p>And I got my bot to say some words in the cmd accurately.
  Next I wanted to add a simple gui.</p>
  <p>I'd much rather it look more chatty but all I could come up with with my lacking coding experince is a simple window with 2 buttons and 2 texts.</p>
  <p>The cood looks like this:</p>
  <pre><code>import aiml
  import PySimpleGUI as sg
  
  kernel = aiml.Kernel()
  kernel.learn(&quot;std-startup.xml&quot;)
  kernel.respond(&quot;load aiml b&quot;)
  sg.theme('LightBlue 1')
  layout = [[sg.Text('You: '), sg.Text(size=(12,1), key='-mytext-')],
            [sg.Text('Csigusz Foxoup (bot): '), sg.Text(size=(12,1), key='-CSI-')],
            [sg.Input(key='-myinput-')],
            [sg.Button('Send message'), sg.Button('Bye!')]]
  
  window = sg.Window('Csigusz Foxoup, your friend in a box (bot)', layout, [200,400])
  
  
  while True:
      event = window.read()
      values = window.read()
      if event == sg.WIN_CLOSED or event == 'Bye!':
          break
      if event == 'Send message':
          # change the &quot;output&quot; element to be the value of &quot;input&quot; element
          input_text = (values)
          response = kernel.respond(input_text)
          window['-mytext-'].update(values['-myinput-'])
          print(&quot;Csigusz Foxoup(bot): &quot;+response)
  
  window.close()
      
  </code></pre>
  <p>And it produces a nice little window for me. <a href="https://i.stack.imgur.com/K36sw.png" rel="nofollow noreferrer">looks like this</a></p>
  <p>My problem is that when I type something, and click the buttons, nothing happens. When I press close window (X) I get an error message saying: &quot;You have tried 100 times to read a closed window, you need to add a check for event == WIN_CLOSED, ERROR&quot;</p>
  <p>Now since i have a check, also a button, I have no idea why it doesnt work. Also don't know how I could get the button to send my bot the user text then retrieve the bot output.</p>
  <p>What Am I doing wrong? Thank you for all replies in advance. All help greatly appreciated! </p>