J'ai un problème plutôt étrange, regardez le code source suivant
import sys, gtk, threading
def test(*args):
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Plop")
dialog.run()
dialog.destroy()
def test_thread():
gtk.gdk.threads_enter()
test()
gtk.gdk.threads_leave()
def test_threaded(*args):
threading.Thread(target=test_thread).start()
gtk.gdk.threads_init()
w = gtk.Window(gtk.WINDOW_TOPLEVEL)
b1 = gtk.Button("gtk.Dialog dans le thread principal")
b2 = gtk.Button("gtk.Dialog dans un autre thread")
h = gtk.HButtonBox()
b1.connect("clicked", test)
b2.connect("clicked", test_threaded)
w.add(h)
h.pack_start(b1)
h.pack_start(b2)
w.show_all()
gtk.main()
Lorsque l'on créé un gtk.Dialog dans le thread principal, tout fonctionne correctement
Ensuite, (…)