1 """<title>an example of layout usage</title>"""
3 from pygame.locals import *
5 # the following line is not needed if pgu is installed
6 import sys; sys.path.insert(0, "..")
12 screen = pygame.display.set_mode((320,320),SWSURFACE)
19 l = layout.Layout(pygame.Rect(0,0,320,320))
22 e.image = pygame.image.load("cuzco.png")
23 e.rect = pygame.Rect(0,0,e.image.get_width(),e.image.get_height())
25 l.add(e) #aligned object
27 font = pygame.font.SysFont("default", 24)
31 l.add(-1) #start of new block
32 for word in """Welcome to my little demo of the layout module. The demo does not do a whole lot, but I'm sure you will be very impressed by it. blah blah blah. The demo does not do a whole lot, but I'm sure you will be very impressed by it. blah blah blah.""".split(" "):
34 e.image = font.render(word,1,fg)
35 e.rect = pygame.Rect(0,0,e.image.get_width(),e.image.get_height())
36 l.add(e) #inline object
41 ##The layout object will layout words, and document elements for you
43 l.add(-1) #start of new block
44 for word in """The demo does not do a whole lot, but I'm sure you will be very impressed by it. blah blah blah. The demo does not do a whole lot, but I'm sure you will be very impressed by it. blah blah blah.""".split(" "):
46 e.image = font.render(word,1,fg)
47 e.rect = pygame.Rect(0,0,e.image.get_width(),e.image.get_height())
48 l.add(e) #inline object
55 screen.blit(e.image,(e.rect.x,e.rect.y))
61 for e in pygame.event.get():
62 if e.type is QUIT: _quit = 1