检查Gtk mainloop是否正在运行

Dan*_*ley 4 python gtk multithreading pygobject

有没有办法可以检查Gtk.main()循环是否还活着?与threading.is_alive()函数类似?任何帮助深表感谢 :)

Ara*_*Fey 6

你可以使用这个Gtk.main_level()功能:

 Gtk.main_level()
    Returns:    the nesting level of the current invocation of the main loop
Run Code Online (Sandbox Code Playgroud)

换句话说,返回值为0表示没有正在运行的主循环.