Skip to main content

DummyVideoDriver — wiki

You can use PyGame without opening a visible display (e.g. for testing, or for integrating with other frameworks that have their own displays) by using SDL environment variables before you initialise pygame. Environment variables can be set with the os.environ dict in python.

import os

os.environ['SDL_VIDEODRIVER'] = 'dummy'
import pygame

while 1:
    events = pygame.event.get()
    for e in events:

A full list of SDL environment variables can be found here.