Skip to main content
`Ctrl`+`K`

# vispy.app.application module

Implements the global singleton app object.

class vispy.app.application.Application(backend_name=None)

  Bases: `object`

  Representation of the vispy application

  This wraps a native GUI application instance. Vispy has a default instance of this class that can be created/obtained via vispy.app.use_app().

  Parameters:
    backend_name str | None

      The name of the backend application to use. If not specified, Vispy tries to select a backend automatically. See `vispy.use()` for details.

  Notes

  Upon creating an Application object, a backend is selected, but the native backend application object is only created when create() is called or native is used. The Canvas and Timer do this automatically.

  property backend_module

    The module object that defines the backend.

  property backend_name

    The name of the GUI backend that this app wraps.

  create()

    Create the native application.

  is_interactive()

    Determine if the user requested interactive mode.

  is_notebook()

    Determine if the user is executing in a Jupyter Notebook

  property native

    The native GUI application instance.

  process_events()

    Process all pending GUI events. If the mainloop is not running, this should be done regularly to keep the visualization interactive and to keep the event system going.

  quit()

    Quit the native GUI event loop.

  reuse()

    Called when the application is reused in an interactive session. This allow the backend to do stuff in the client when use_app() is called multiple times by the user. For example, the notebook backends need to inject JavaScript code as soon as use_app() is called.

  run(allow_interactive=True)

    Enter the native GUI event loop.

    Parameters:
      allow_interactive bool

        Is the application allowed to handle interactive mode for console terminals? By default, typing `python -i main.py` results in an interactive shell that also regularly calls the VisPy event loop. In this specific case, the run() function will terminate immediately and rely on the interpreter’s input loop to be run after script execution.

  sleep(duration_sec)

    Sleep for the given duration in seconds.

    This is used to reduce CPU stress when VisPy is run in interactive mode.

    Parameters:
      duration_sec: float

        Time to sleep in seconds