title: BadWindow crash in tkinter after calling glfw.init()
body: <p>I have the following code, which works on Windows, but crashes on Linux with X11:</p>
  <pre class="lang-py prettyprint-override"><code>#! /usr/bin/env python3
  &quot;&quot;&quot;Tkinter crashes on X11 when popup windows
  are closed after calling glfw.init()
  &quot;&quot;&quot;
  
  from sys import exit
  
  from tkinter import Tk
  from tkinter.messagebox import showinfo
  
  from glfw import init
  
  
  class MainWindow(Tk):
      &quot;&quot;&quot;Main window.&quot;&quot;&quot;
  
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
  
          if not init():
              exit(2)
  
          showinfo('Close me', 'I dare you')
  
  
  def main():
      &quot;&quot;&quot;Run the script.&quot;&quot;&quot;
  
      MainWindow().mainloop()
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  <p>After clicking <em>OK</em> in the message box on Linux/X11, the program crashes with:</p>
  <pre><code>X Error of failed request:  BadWindow (invalid Window parameter)
    Major opcode of failed request:  15 (X_QueryTree)
    Resource id in failed request:  0x4c0000a
    Serial number of failed request:  778
    Current serial number in output stream:  778
  </code></pre>
  <p>The addresses vary after each run, but the overall error stays the same.<br />
  I was able to reduce the problem to the call of <code>glfw.init()</code> which results in subsequent closing of tkinter Windows to crash the program. However, this does not happen on Windows systems.</p>
  <p>Some system info:</p>
  <pre><code>$ uname -r
  5.16.16-arch1-1
  $ pacman -Q xorg-server
  xorg-server 21.1.3-6
  $ echo $XDG_SESSION_TYPE
  x11
  $ pacman -Q glfw python-glfw
  glfw-x11 3.3.6-1
  python-glfw 2.1.0-2
  </code></pre>
  <p>Why is this program crashing on my system?<br />
  What can I do to make it run just like on windows?</p>