Skip to content
PySDL is a pure Python SDL binding via on-the-fly ctypes generation
Python C
Latest commit e7c8535 Apr 6, 2013 @albertz Update README.md
Failed to load latest commit information.
SDL
cparser enum consts: increment chars Feb 7, 2012
.gitignore gitignore Feb 7, 2012
README.md
better_exchook.py updated better_exchook Oct 4, 2011
example1.py python 2to3 on example1.py Oct 4, 2011
example2.png example2 initial. by Gabriel Jacobo Jul 7, 2011
example2.py again the fix for SDL 1.3 as in example1 Jul 7, 2011

README.md

PySDL

Similar projects first:

  • The equally named PySDL on SourceForge. Last update was from 2000. Implemented in C.
  • Pygame. Actively developed. Implemented in C. Is not a straight-forward 1:1 binding to SDL but has a different API.

How does this PySDL differ?

  • Purely implemented in Python.
  • On-the-fly ctypes generation from the SDL.h.
  • Straight-forward 1:1 binding to SDL.

How is it implemented?

It uses PyCParser to automatically parse the SDL headers and to generate a ctypes interface to the library.

TODOs

  • I only tested it on MacOSX yet. There I needed some additional ObjC/Cocoa initializing code. Basically the stuff in SDLmain.m. Maybe similar stuff is needed on other architectures. Maybe it would also be possible to search for the SDLmain.a and just call the main in there. However, there is already a report that it also works on Linux.
  • Some more testing. Some more complex example.
  • The interface generated by PyCParser could be cached so it doesn't has to be recreated each time it is started. This has become less important though since the C parser already supports caching itself at least for the parsing part.
  • Maybe it makes sense to provide an (possibly optional) additional wrapper around SDL_Surface* which calls SDL_FreeSurface in its __del__ method.
  • PyCParser could be extended. It works just enough so that it is able to fully parse the SDL headers.

--- Albert Zeyer

Something went wrong with that request. Please try again.