annotate pyntnclick/tools/utils.py @ 691:60bf20849231 pyntnclick

Fix detail loading in rect_drawer. Improve error reporting when loading fails
author Neil Muller <neil@dip.sun.ac.za>
date Tue, 14 Feb 2012 13:05:10 +0200
parents 4a933444c99b
children f4853f817a7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
589
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
1 # Misc utils I don't know where else to put
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
2
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
3
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
4 def list_scenes(get_initial_state):
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
5 """List the scenes in the state"""
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
6 state = get_initial_state()
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
7 print 'Available scenes are : '
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
8 for scene in state.scenes:
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
9 print ' ', scene
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
10 print 'Available details are : '
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
11 for detail in state.detail_views:
ebc48b397fd5 Turn rect_drawer into a command line option
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
12 print ' ', detail
690
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
13
691
60bf20849231 Fix detail loading in rect_drawer. Improve error reporting when loading fails
Neil Muller <neil@dip.sun.ac.za>
parents: 690
diff changeset
14
690
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
15 def draw_rect_image(surface, color, rect, thickness):
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
16 """Draw a rectangle with lines thickness wide"""
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
17 # top
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
18 surface.fill(color, (rect.left, rect.top, rect.width, thickness))
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
19 # bottom
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
20 surface.fill(color, (rect.left, rect.bottom - thickness, rect.width,
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
21 thickness))
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
22 # left
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
23 surface.fill(color, (rect.left, rect.top, thickness, rect.height))
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
24 # right
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
25 surface.fill(color, (rect.right - thickness, rect.top, thickness,
4a933444c99b The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents: 589
diff changeset
26 rect.height))