[Edu-sig] Simple frame buffer module

Pete Shinners pete@shinners.org
Tue, 28 Aug 2001 18:03:15 -0700


 > I'd like to announce the simple frame buffer module that
 > I wacked together after being fed up with having to create
 > a GUI every time I wanted to illustrate something simple
 > in Python (such as the iterative improvement of some problem).
 > A short sample:
 >
 >  import fb                       # import module
 >  f = fb.FrameBuffer()            # create an instance
 >  f.open(200, 200, "demo")        # open a window named "demo"
 >  for i in range(10, 190):        # simple loop
 >    f.fg = (i, i, i)             # set fg colour
 >    f.plot(i, i)                  # plot
 >  f.flip()                        # flip buffers
 >  raw_input('enter to quit')      # wait for keypress
 >  f.close()                       # close window

it is nice to see more support for graphics based stuff
coming in python. i'm the author of pygame, which does
very similar things with SDL, http://www.pygame.org

pygame is more of a full-coverage wrapping for the SDL
library, which could make it a bit top-heavy for someone
looking for simple framebuffer access. still, it can
perform like this above example without too much extra
overhead.

pygame.init()                           #initialize
f = pygame.display.set_mode((200,200))  #open framebuffer
for i in range(10, 190):
     f.set_at((i, i), (i, i, i))         #set grey pixels
pygame.display.flip()                   #flip buffers
while pygame.event.wait().type not in (QUIT,KEYDOWN):
     pass                                #wait for input
pygame.quit()                           #optional quit