sdl2.ext.common - Frequently Used SDL2 Functions

This module wraps various common SDL2 functions, including methods for initializing and quitting SDL2 and its various subsystems and for retrieving events from the SDL2 event queue.

exception sdl2.ext.common.SDLError(msg=None)[source]

An SDL2-specific exception class.

sdl2.ext.common.init()[source]

Initializes the SDL2 video subsystem.

See pygame for a comparison between this function and pygame.init().

Raises:SDLError – If the SDL2 video subsystem cannot be initialized.
sdl2.ext.common.quit()[source]

Quits the SDL2 video subysystem.

If no other subsystems are active, this will also call sdl2.SDL_Quit(), sdlttf.TTF_Quit() and sdlimage.IMG_Quit().

sdl2.ext.common.get_events()[source]

Gets all SDL events that are currently on the event queue.

Returns:A list of all SDL_Event objects currently in the event queue.
Return type:List
class sdl2.ext.common.TestEventProcessor[source]

A simple event processor for testing purposes.

run(window)[source]

Starts an event loop without actually processing any event.

This method will run endlessly until an SDL_QUIT event occurs.

Parameters:window (sdl2.ext.Window) – The window within which to run the test event loop.