title: Tkinter RuntimeError: main thread is not in main loop when trying to insert item into listbox from different thread
body: <p>Whenever I try to insert an item into a tkinter listbox from another thread it gives me this error: <code>RuntimeError: main thread is not in main loop</code> The main parts of my code is down here:
  Receive Thread:</p>
  <pre><code># receive is running on another thread
  def receive(event=None):
      global msg
      global recvinfo
      while True:
          try:
              msg = client_socket.recv(BUFSIZ).decode(&quot;utf8&quot;)
              decoded = cryptocode.decrypt(msg, PASS)
              if decoded == &quot;User Found&quot;:
                  recvinfo = 1
              elif decoded == &quot;User Not Found&quot;:
                  recvinfo = 2
              elif decoded.startswith(&quot;gb:&quot;):
                  smsg_list.insert(tkinter.END, decoded)
          except OSError:  # Client Side Exited Out
              break
  </code></pre>
  <p>GUI Definition, running in main loop:</p>
  <pre><code>def maingui():
  
      global smsg_list
  
      receive_thread = Thread(target=receive)
      receive_thread.start()
  
      smsg_list = tkinter.Listbox(smessages_frame, height=&quot;21&quot;, width=&quot;75&quot;,)
      smsg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH)
      smsg_list.pack()
  </code></pre>