简体   繁体   English

Python3 +线程+ Gtk3 + MessageDialog

[英]Python3 + Threading + Gtk3 + MessageDialog

I'm working with threading and Gtk.MessageDialog with this Thread: 我正在与此线程一起使用线程和Gtk.MessageDialog:

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. 但是当第二次(或第三次等等)被调用时,MesageDialog出现,但是主体是透明的,没有任何消息。

GTK+ (like most toolkits) is not thread-safe. GTK +(像大多数工具包一样)不是线程安全的。 You can create threads, but you can only use them to pass data to the main thread used by GTK+. 您可以创建线程,但是只能使用它们将数据传递给GTK +使用的主线程。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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