Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/data/graphics/slideshow
blob: 0d38ab854e04c390e170a1786e0268f0f88efbde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# slideshow: show datastore photos 
def pippy_activity_class(): return 'activity.PyGameActivity'
if __name__ == '__main__':
  import gst, pippy, pygame, sys, time
  from pippy import query

  from random import *

  # XO screen is 1200 by 900
  size = width, height = 1200, 900

  # grey background
  bgcolor = (128,128,128)
  
  # Create a search dict
  search = {}
  search["mime_type"] = "image/jpeg"

  # Perform the search and retrieve the jobjects
  results = query.find(search)
  # XXX: Fix caching limit in query.py
  objects = results.read(15)

  if len(objects) == 0:
    print "No photos found."
    time.sleep(3)
    sys.exit()

  def get_image():
    for jobject in objects:
      yield jobject.get_file_path()

  next_image = get_image()

  # pygame always needs to be initialized as the first call
  pygame.init()

  # turn off cursor
  pygame.mouse.set_visible(False)

  # create the pygame window at the desired size and return a Surface object for
  # drawing in that window.
  screen = pygame.display.set_mode(size)

  # load in previously grabbed frame
  image = pygame.image.load(next_image.next())

  while pippy.pygame.next_frame():
    for event in pygame.event.get():
      if event.type == pygame.QUIT: sys.exit()
      elif event.type == pygame.KEYDOWN:
        try:
          image = pygame.image.load(next_image.next())
        except StopIteration:
          sys.exit()

    # Scale up from 640x480 -> 1280x960
    newImage = pygame.transform.rotozoom(image, 0, 2.0)
    newImageRect = newImage.get_rect()
    newImageRect.centerx = screen.get_rect().centerx
    newImageRect.centery = screen.get_rect().centery

    screen.fill(bgcolor)
    screen.blit(newImage, newImageRect)
    pygame.display.flip()