elif event.key == pygame.K_RETURN:
return sel_answer
+# function displaying the contents of a container. Object must contain
+# items list
+# edgewidth - container edges to avoid drawing items in
+def display_container_contents (surface, obj, bgimage, edgewidth=0):
+
+ # get the number of items
+ numitems = len (obj.objects)
+ # number of rows
+ num_rows = (bgimage.get_height () - edgewidth*2) / 48
+ # number of cols
+ num_cols = (bgimage.get_width () - edgewidth*2) / 48
+
+ objposx = surface.get_width()/2 - bgimage.get_width()/2
+ objposy = surface.get_height()/2 - bgimage.get_height()/2
+
+ while 1:
+ # display the background for the container
+ surface.blit (bgimage, (objposx, objposy))
+
+ # display each item in the container
+ i = 0
+ j = 0
+
+ for item in obj.objects:
+ surface.blit (item.image, (objposx + edgewidth+ j*48, objposy + edgewidth + i*48))
+ j += 1
+ if j >= num_cols:
+ j = 0
+ i += 1
+ # only display as many items as will fit in the container
+ if i >= num_rows:
+ break
+
+ pygame.display.update ()
+ for event in pygame.event.get ():
+ if event.type == pygame.QUIT:
+ sys.exit (0)
+ elif event.type == pygame.KEYDOWN:
+ if event.key == pygame.K_ESCAPE:
+ return