Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

343
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda