简体   繁体   中英

Python3 + Threading + Gtk3 + MessageDialog

I'm working with threading and Gtk.MessageDialog with this Thread:

class DialogueAttente(Thread):
def __init__(self):
    Thread.__init__(self)
    self.message=Gtk.MessageDialog(None,Gtk.DialogFlags.MODAL,Gtk.MessageType.INFO,Gtk.ButtonsType.NONE,"Diagnostic en cours")

def run(self):
    self.message.run()

def join(self):
    self.message.destroy()

This runs great when I call it, the first time. But when it's called a second time (or third etc ...), the MesageDialog comes up, but the body is transparent, without any message.

GTK+ (like most toolkits) is not thread-safe. You can create threads, but you can only use them to pass data to the main thread used by GTK+.

See https://wiki.gnome.org/Projects/PyGObject/Threading

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM