[Python] Tkinter locks Python when an icon is loaded and tk.mainloop is in a thread

Discussão em 'Python' iniciado por Stack, Março 11, 2025.

  1. Stack

    Stack Membro Participativo

    Here's the test case...

    import Tkinter as tk
    import thread
    from time import sleep

    if __name__ == '__main__':
    t = tk.Tk()
    thread.start_new_thread(t.mainloop, ())
    # t.iconbitmap('icon.ico')

    b = tk.Button(text='test', command=exit)
    b.grid(row=0)

    while 1:
    sleep(1)


    This code works. Uncomment the t.iconbitmap line and it locks. Re-arrange it any way you like; it will lock.

    How do I prevent tk.mainloop locking the GIL when there is an icon present?

    The target is win32 and Python 2.6.2.

    Continue reading...

Compartilhe esta Página