Contains routines to work with the display. Mainly used for setting the display mode and updating the display surface.


  • pygame.display.quit() -> none
  • - uninitialize the display module
  • pygame.dislay.init() -> None
  • - initialize the display module
  • pygame.display.get_init() -> bool
  • - get status of display module initialization
  • pygame.display.get_active() -> bool
  • - get state of display mode
  • pygame.display.set_driver(name) -> none
  • - override the default sdl video driver
  • pygame.display.get_driver() -> name
  • - get the current sdl video driver
  • pygame.display.get_info() -> VidInfo
  • - get display capabilities and settings
  • pygame.display.get_surface() -> Surface
  • - get current display surface
  • pygame.display.set_mode(size, [flags, [depth]]) ->
  • - Surface
  • pygame.display.mode_ok(size, [flags, [depth]]) ->
  • - int
  • pygame.display.list_modes([depth, [flags]]) ->
  • - [(x,y),...] | -1
  • pygame.display.flip() -> None
  • - update the display
  • pygame.display.update([rectstyle]) -> None
  • - pygame.display.update(list of rectstyles) -> None
  • pygame.display.set_gamma(r, [g, b]) -> bool
  • - change the brightness of the display
  • pygame.display.doc_set_caption(title, [icontitle])
  • - -> None
  • pygame.display.doc_get_caption() -> (title,
  • - icontitle)
  • pygame.display.iconify() -> bool
  • - minimize the display window
  • pygame.display.toggle_fullscreen() -> bool
  • - switch the display fullscreen mode


    pygame.display.quit() -> none

    Manually uninitialize SDL's video subsystem. It is safe to call this if the video is currently not initialized.


    pygame.dislay.init() -> None

    Manually initialize SDL's video subsystem. Will raise an exception if it cannot be initialized. It is safe to call this function if the video has is currently initialized.


    pygame.display.get_init() -> bool

    Returns true if SDL's video system is currently intialized.


    pygame.display.get_active() -> bool

    Returns true if the current display is active on the screen. This done with the call to pygame.display.set_mode(). It is potentially subject to the activity of a running window manager.


    pygame.display.set_driver(name) -> none

    Changes the SDL environment to initialize with the given named videodriver. This can only be changed before the display is initialized. If this is not called, SDL will use it's default video driver, or the one in the environment variable SDL_VIDEODRIVER.


    pygame.display.get_driver() -> name

    Once the display is initialized, this will return the name of the currently running video driver. There is no way to get a list of all the supported video drivers.


    pygame.display.get_info() -> VidInfo

    Gets a vidinfo object that contains information about the capabilities and current state of the video driver. This can be called before the display mode is set, to determine the current video mode of a display.


    pygame.display.get_surface() -> Surface

    Returns a Surface object representing the current display. Will return None if called before the display mode is set.


    pygame.display.set_mode(size, [flags, [depth]]) ->

    Sets the current display mode. If calling this after the mode has already been set, this will change the display mode to the desired type. Sometimes an exact match for the requested video mode is not available. In this case SDL will try to find the closest match and work with that instead. The size is a 2-number-sequence containing the width and height of the desired display mode. Flags represents a set of different options for the new display mode. If omitted or given as 0, it will default to a simple software window. You can mix several flags together with the bitwise-or (|) operator. Possible flags are HWSURFACE (or the value 1), HWPALETTE, DOUBLEBUF, and/or FULLSCREEN. There are other flags available but these are the most usual. A full list of flags can be found in the SDL documentation. The optional depth arguement is the requested bits per pixel. It will usually be left omitted, in which case the display will use the best/fastest pixel depth available.


    pygame.display.mode_ok(size, [flags, [depth]]) ->

    This uses the same arguments as the call to pygame.display.set_mode(). It is used to determine if a requested display mode is available. It will return 0 if the requested mode is not possible. Otherwise it will return the best and closest matching bit depth for the mode requested. The size is a 2-number-sequence containing the width and height of the desired display mode. Flags represents a set of different options for the display mode. If omitted or given as 0, it will default to a simple software window. You can mix several flags together with the bitwise-or (|) operator. Possible flags are HWSURFACE (or the value 1), HWPALETTE, DOUBLEBUF, and/or FULLSCREEN. There are other flags available but these are the most usual. A full list of flags can be found in the SDL documentation. The optional depth arguement is the requested bits per pixel. It will usually be left omitted, in which case the display will use the best/fastest pixel depth available.


    pygame.display.list_modes([depth, [flags]]) ->

    This function returns a list of possible dimensions for a specified color depth. The return value will be an empty list of no display modes are available with the given arguments. A return value of -1 means that any requested resolution should work (this is likely the case for windowed modes). Mode sizes are sorted from biggest to smallest. If depth is not passed or 0, SDL will choose the current/best color depth for the display. You will usually want to pass FULLSCREEN when using the flags, if flags is omitted, FULLSCREEN is the default.


    pygame.display.flip() -> None

    This will update the contents of the entire display. If your display mode is using the flags HWSURFACE and DOUBLEBUF, this will wait for a vertical retrace and swap the surfaces. If you are using a different type of display mode, it will simply update the entire contents of the surface.


    pygame.display.update([rectstyle]) -> None

    This call will update a section (or sections) of the display screen. You must update an area of your display when you change its contents. If passed with no arguments, this will update the entire display surface. If you have many lists that need updating, it is best to combine them into a sequence and pass them all at once.


    pygame.display.set_gamma(r, [g, b]) -> bool

    Sets the display gamma to the given amounts. If green and blue are ommitted, the red value will be used for all three colors. The color arguments are floating point values with 1.0 being the normal value. If you are using a display mode with a hardware palette, this will simply update the palette you are using. Not all hardware supports gamma. The return value will be true on success.


    pygame.display.doc_set_caption(title, [icontitle])

    If the display has a window title, this routine will change the name on the window. Some environments support a shorter icon title to be used when the display is minimized. If icontitle is omittied it will be the same as caption title.


    pygame.display.doc_get_caption() -> (title,

    Returns the current title and icontitle for the display window.


    pygame.display.iconify() -> bool

    Tells the window manager (if available) to minimize the application. The call will return true if successful. You will receive an APPACTIVE event on the event queue when the window has been minimized.


    pygame.display.toggle_fullscreen() -> bool

    Tells the window manager (if available) to switch between windowed and fullscreen mode. If available and successfull, will return true. Note, there is currently limited platform support for this call.