title: Python, threading issue when using pysimplegui and tkPDFViewer
body: <p>I'm new to Python and I'm running into a &quot;RuntimeError: main thread is not in mainloop&quot;, I understand it is a threading issue, something to do with using PySimpleGui and tkPDFviewer together. Sample code below creates a main window, opening the pysimplegui window by itself is fine, opening the PDF window by itself is fine. However after opening the pysimplegui window the PDF window then throws the runtime error and refuses to open. Any advice would be appreciated.</p>
  <pre><code>import tkinter as tk
  import PySimpleGUI as sg
  
  from tkinter import ttk
  from tkPDFViewer import tkPDFViewer as pdf
  
  #Main
  class Main(tk.Tk):
  
      #init main
      def __init__(self, *args, **kwargs):
  
          #init tk()
          tk.Tk.__init__(self, *args, **kwargs)
    
          SIMPLEGUI_BUTTON = ttk.Button(self, text=&quot;SIMPLE GUI&quot;, command=lambda: the_gui())
          PDF_Button = ttk.Button(self, text=&quot;PDF&quot;, command=lambda: PDFWindow())
          SIMPLEGUI_BUTTON.grid()
          PDF_Button.grid()
  
  #simple gui window
  def the_gui():
      layout = [[]]
  
      window = sg.Window('Window', layout)
  
      while True:
          event, values = window.read()
          if event in (sg.WIN_CLOSED, 'Exit'):
              break
  
      window.close()
  
  #PDF Window
  class PDFWindow(tk.Frame):
  
      #init main
      def __init__(self):
  
          #init tk()
          tk.Frame.__init__(self)
  
          window = tk.Toplevel(self)
          
          v1 = pdf.ShowPdf()
          v2 = v1.pdf_view(master=window, pdf_location=&quot;C:\\Users\\Documents\\2021-07-30.pdf&quot;, width=200, height=100)
          v2.pack(side=&quot;bottom&quot;, fill=&quot;both&quot;)
  
  if __name__ == '__main__':
      
      app = Main()
      app.mainloop()
  </code></pre>
  <p>Traceback:</p>
  <pre><code>Exception in thread Thread-1:
  Traceback (most recent call last):
    File &quot;C:\Users\AppData\Local\Programs\Python\Python39\lib\threading.py&quot;, line 954, in _bootstrap_inner
      self.run()
    File &quot;C:\Users\AppData\Local\Programs\Python\Python39\lib\threading.py&quot;, line 892, in run
      self._target(*self._args, **self._kwargs)
    File &quot;C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\tkPDFViewer\tkPDFViewer.py&quot;, line 49, in add_img
      timg = PhotoImage(data = img)
    File &quot;C:\Users\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py&quot;, line 4064, in __init__
      Image.__init__(self, 'photo', name, cnf, master, **kw)
    File &quot;C:\Users\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py&quot;, line 4009, in __init__
      self.tk.call(('image', 'create', imgtype, name,) + options)
  RuntimeError: main thread is not in main loop
  Exception ignored in: &lt;function Variable.__del__ at 0x0000023E408EBDC0&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py&quot;, line 363, in __del__
      if self._tk.getboolean(self._tk.call(&quot;info&quot;, &quot;exists&quot;, self._name)):
  RuntimeError: main thread is not in main loop
  </code></pre>