:right-sidebar: True MainLoop =================================================================== .. currentmodule:: gi.repository.GLib .. class:: MainLoop(context=None) :no-contents-entry: The ``GMainLoop`` struct is an opaque data type representing the main event loop of a GLib or GTK application. Constructors ------------ .. rst-class:: interim-class .. class:: MainLoop :no-index: .. classmethod:: new(context: ~gi.repository.GLib.MainContext | None, is_running: bool) -> ~gi.repository.GLib.MainLoop Creates a new :obj:`~gi.repository.GLib.MainLoop` structure. :param context: a :obj:`~gi.repository.GLib.MainContext` (if :const:`None`, the global-default main context will be used). :param is_running: set to :const:`True` to indicate that the loop is running. This is not very important since calling :obj:`~gi.repository.GLib.MainLoop.run` will set this to :const:`True` anyway. Methods ------- .. rst-class:: interim-class .. class:: MainLoop :no-index: .. method:: get_context() -> ~gi.repository.GLib.MainContext Returns the :obj:`~gi.repository.GLib.MainContext` of ``loop``\. .. method:: is_running() -> bool Checks to see if the main loop is currently being run via :obj:`~gi.repository.GLib.MainLoop.run`\. .. method:: quit() -> None Stops a :obj:`~gi.repository.GLib.MainLoop` from running. Any calls to :obj:`~gi.repository.GLib.MainLoop.run` for the loop will return. Note that sources that have already been dispatched when :obj:`~gi.repository.GLib.MainLoop.quit` is called will still be executed. .. method:: run() Runs a main loop until :obj:`~gi.repository.GLib.MainLoop.quit` is called on the loop. If this is called for the thread of the loop's :obj:`~gi.repository.GLib.MainContext`\, it will process events from the loop, otherwise it will simply wait.