这是测试案例......
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)
Run Code Online (Sandbox Code Playgroud)
这段代码有效.取消注释t.iconbitmap行并锁定.以你喜欢的方式重新安排它; 它会锁定.
当存在图标时,如何防止tk.mainloop锁定GIL?
目标是win32和Python 2.6.2.