gobject.MainLoop

gobject.MainLoop — an object representing the main event loop of a PyGTK application.

Synopsis

class gobject.MainLoop:
    gobject.MainLoop(context=None, is_running=0)
def get_context()
def is_running()
def quit()
def run()

Ancestry

+-- gobject.MainLoop

Description

gobject.MainLoop represents a main event loop. A gobject.MainLoop is created with the gobject.MainLoop() constructor. After adding the initial event sources, the run() method is called. This continuously checks for new events from each of the event sources and dispatches them. Finally, the processing of an event from one of the sources leads to a call to the quit() method to exit the main loop, and the run() method returns.

It is possible to create new instances of gobject.MainLoop recursively. This is often used in PyGTK applications when showing modal dialog boxes. Note that event sources are associated with a particular gobject.MainContext, and will be checked and dispatched for all main loops associated with that gobject.MainContext.

PyGTK contains wrappers of some of these functions, e.g. the gtk.main(), gtk.main_quit() and gtk.events_pending() functions.

Constructor

    gobject.MainLoop(context=None, is_running=None)
context :a gobject.MainContext or None to use the default context.
is_running :if TRUE indicates that the loop is running. This is not very important since calling the run() method will set this to TRUE anyway.
Returns :a new gobject.MainLoop object.

Creates a new gobject.MainLoop object.

Methods

gobject.MainLoop.get_context

    def get_context()
Returns :the gobject.MainContext the mainloop is associated with

The get_context() method returns the gobject.MainContext that the mainloop was created with.

gobject.MainLoop.is_running

    def is_running()
Returns :TRUE if the mainloop is currently being run.

The is_running() method checks to see if the mainloop is currently being run via the run() method.

gobject.MainLoop.quit

    def quit()

The quit() method stops the mainloop from running. Any subsequent calls to the run() method will return immediately.

gobject.MainLoop.run

    def run()

The run() method runs a mainloop until the quit() method is called. If this is called for the thread of the loop's gobject.MainContext, it will process events from the loop, otherwise it will simply wait.