Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

342
Vistas
BadWindow crash in tkinter after calling glfw.init()

I have the following code, which works on Windows, but crashes on Linux with X11:

#! /usr/bin/env python3
"""Tkinter crashes on X11 when popup windows
are closed after calling glfw.init()
"""

from sys import exit

from tkinter import Tk
from tkinter.messagebox import showinfo

from glfw import init


class MainWindow(Tk):
    """Main window."""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        if not init():
            exit(2)

        showinfo('Close me', 'I dare you')


def main():
    """Run the script."""

    MainWindow().mainloop()


if __name__ == '__main__':
    main()

After clicking OK in the message box on Linux/X11, the program crashes with:

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

The addresses vary after each run, but the overall error stays the same.
I was able to reduce the problem to the call of glfw.init() which results in subsequent closing of tkinter Windows to crash the program. However, this does not happen on Windows systems.

Some system info:

$ 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

Why is this program crashing on my system?
What can I do to make it run just like on windows?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I'm not an expert on this, but if you only want to have working code you have to call glfw.init() before super().__init__() like this:

from tkinter import Tk
from tkinter.messagebox import showinfo

from glfw import init


class MainWindow(Tk):
    """Main window."""

    def __init__(self, *args, **kwargs):
        if not init():
            exit(2)
        super().__init__(*args, **kwargs)

        showinfo('Close me', 'I dare you')


def main():
    """Run the script."""
    MainWindow().mainloop()


if __name__ == '__main__':
    main()

I think it is better to put the glfw.init() in main before MainWindow().mainloop(), but i wanted to make clear that i think the problem is directly in super().__ini__().

I did not tested any function of glfw, i only checked this because of other questions on SO

Here are some links you can check, maybe they can help: togl code project

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda