Source

pygame / examples / sdl / hello_world.py

Full commit
marcus be97d66 
marcus 853cd73 















marcus be97d66 

marcus 853cd73 
marcus be97d66 





marcus 853cd73 
marcus 86ce793 



marcus 853cd73 
marcus be97d66 









import sys, os
import pygame2
try:
    import pygame2.sdl.constants as constants
    import pygame2.sdl.event as event
    import pygame2.sdl.video as video
except ImportError:
    print ("No pygame2.sdl support")
    sys.exit ()

try:
    import pygame2.sdlimage as image
    hassdlimage = True
except ImportError:
    hassdlimage = False
    import pygame2.sdl.image as image

def run():
    video.init ()

    imgdir = os.path.dirname (os.path.abspath (__file__))
    surface = None
    if hassdlimage:
        surface = image.load (os.path.join (imgdir, "logo.gif"))
    else:
        surface = image.load_bmp (os.path.join (imgdir, "logo.bmp"))

    screen = video.set_mode (surface.w + 10, surface.h + 10)
    screen.fill (pygame2.Color (255, 255, 255))
    screen.blit (surface, (5, 5))
    screen.flip ()

    okay = True
    while okay:
        for ev in event.get ():
            if ev.type == constants.QUIT:
                okay = False
            if ev.type == constants.KEYDOWN and ev.key == constants.K_ESCAPE:
                okay = False
    video.quit ()

if __name__ == "__main__":
    run ()