Mercurial > boomslang
annotate pyntnclick/tools/utils.py @ 758:f4853f817a7a pyntnclick
Refactor scene listing, to avoid having to create a window
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 26 Jan 2013 12:56:21 +0200 |
parents | 60bf20849231 |
children |
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 |
758
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
4 def list_scenes(scene_module, scene_list): |
589
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""" |
758
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
6 print "Available scenes and details:" |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
7 for scene in scene_list: |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
8 scenemod = __import__('%s.%s' % (scene_module, scene), |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
9 fromlist=[scene]) |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
10 if scenemod.SCENES: |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
11 print " * %s" % scene |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
12 else: |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
13 print " * %s (details only)" % scene |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
14 for detailcls in getattr(scenemod, 'DETAIL_VIEWS', []): |
f4853f817a7a
Refactor scene listing, to avoid having to create a window
Stefano Rivera <stefano@rivera.za.net>
parents:
691
diff
changeset
|
15 print " - %s" % detailcls.NAME |
690
4a933444c99b
The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents:
589
diff
changeset
|
16 |
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
|
17 |
690
4a933444c99b
The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents:
589
diff
changeset
|
18 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
|
19 """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
|
20 # top |
4a933444c99b
The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents:
589
diff
changeset
|
21 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
|
22 # bottom |
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.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
|
24 thickness)) |
4a933444c99b
The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents:
589
diff
changeset
|
25 # left |
4a933444c99b
The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents:
589
diff
changeset
|
26 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
|
27 # right |
4a933444c99b
The return of the rects to the rect drawer
Neil Muller <neil@dip.sun.ac.za>
parents:
589
diff
changeset
|
28 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
|
29 rect.height)) |