script for converting ASCII to sgf
[imago.git] / im_debug.py
1 try:
2     import pygame
3 except ImportError, msg:
4     import sys
5     print >>sys.stderr, msg
6     sys.exit(1)
7
8 def show(image, caption='', name=None):
9     if image.mode != 'RGB':
10         image = image.convert('RGB')
11     pygame.init()
12     if caption:
13         caption = "Imago: " + caption
14     else:
15         caption = "Imago"
16     pygame.display.set_caption(caption)
17     pygame.display.set_mode(image.size)
18     main_surface = pygame.display.get_surface()
19     picture = pygame.image.frombuffer(image.tostring(), image.size, image.mode)
20     main_surface.blit(picture, (0, 0))
21     pygame.display.update()
22     while True:
23         events = pygame.event.get()
24         for event in events:
25             if event.type == pygame.QUIT or event.type == pygame.KEYDOWN:
26                 pygame.quit()
27                 return