MainLoop#

class MainLoop(context=None)#

The GMainLoop struct is an opaque data type representing the main event loop of a GLib or GTK application.

Constructors#

class MainLoop
classmethod new(context: MainContext | None, is_running: bool) MainLoop#

Creates a new MainLoop structure.

Parameters:
  • context – a MainContext (if None, the global-default main context will be used).

  • is_running – set to True to indicate that the loop is running. This is not very important since calling run will set this to True anyway.

Methods#

class MainLoop
get_context() MainContext#

Returns the MainContext of loop.

is_running() bool#

Checks to see if the main loop is currently being run via run.

quit() None#

Stops a MainLoop from running. Any calls to run for the loop will return.

Note that sources that have already been dispatched when quit is called will still be executed.

run()#

Runs a main loop until quit is called on the loop. If this is called for the thread of the loop’s MainContext, it will process events from the loop, otherwise it will simply wait.