annotate tools/rect_drawer.py @ 165:9b3bba5e65f3

add some features to rect helper. now vaguely useful
author Neil Muller <neil@dip.sun.ac.za>
date Wed, 25 Aug 2010 11:19:30 +0200
parents 225e3a4b1e85
children a2d041e0ab83
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
1 # Quickly hacked together helper for working out
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
2 # interactive regions in Suspended Sentence
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
3
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
4 import sys
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
5
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
6 from albow.root import RootWidget
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
7 from albow.utils import frame_rect
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
8 from albow.controls import Image, Button
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
9 from albow.palette_view import PaletteView
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
10 from pygame.locals import SWSURFACE
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
11 import pygame
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
12 from pygame.colordict import THECOLORS
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
13
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
14
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
15 class AppPalette(PaletteView):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
16
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
17 sel_width = 5
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
18
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
19 colors = [
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
20 'red', 'maroon1', 'palevioletred1', 'moccasin', 'orange',
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
21 'honeydew', 'yellow', 'gold', 'goldenrod', 'brown',
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
22 'blue', 'purple', 'darkorchid4', 'thistle', 'skyblue1',
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
23 'green', 'palegreen1', 'darkgreen', 'aquamarine', 'darkolivegreen',
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
24 ]
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
25
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
26 def __init__(self, app_image):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
27 self.image = app_image
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
28 super(AppPalette, self).__init__((35, 35), 5, 5, margin=2)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
29 self.selection = 0
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
30 self.image.rect_color = pygame.color.Color(self.colors[self.selection])
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
31
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
32 def num_items(self):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
33 return len(self.colors)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
34
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
35 def draw_item(self, surface, item_no, rect):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
36 d = -2 * self.sel_width
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
37 r = rect.inflate(d, d)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
38 surface.fill(pygame.color.Color(self.colors[item_no]), r)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
39
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
40 def click_item(self, item_no, event):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
41 self.selection = item_no
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
42 self.image.rect_color = pygame.color.Color(self.colors[item_no])
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
43
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
44 def item_is_selected(self, item_no):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
45 return self.selection == item_no
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
46
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
47
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
48
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
49 class AppImage(Image):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
50
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
51 def __init__(self, filename):
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
52 draw_image = pygame.image.load(filename)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
53 super(AppImage, self).__init__(draw_image)
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
54 self.mode = 'draw'
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
55 self.rects = []
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
56 self.start_pos = None
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
57 self.end_pos = None
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
58 self.draw_color = pygame.color.Color('white')
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
59 self.rect_color = pygame.color.Color('white')
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
60
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
61 def draw_mode(self):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
62 self.mode = 'draw'
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
63
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
64 def del_mode(self):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
65 self.mode = 'del'
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
66 self.start_pos = None
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
67 self.end_pos = None
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
68
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
69 def draw(self, surface):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
70 super(AppImage, self).draw(surface)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
71 if self.mode == 'draw' and self.start_pos:
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
72 rect = pygame.rect.Rect(self.start_pos[0], self.start_pos[1],
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
73 self.end_pos[0] - self.start_pos[0],
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
74 self.end_pos[1] - self.start_pos[1])
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
75 frame_rect(surface, self.draw_color, rect, 2)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
76 for (col, rect) in self.rects:
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
77 frame_rect(surface, col, rect, 1)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
78
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
79 def _make_dict(self):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
80 d = {}
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
81 for col, rect in self.rects:
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
82 d.setdefault(col, [])
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
83 d[col].append(rect)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
84 return d
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
85
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
86 def print_rects(self):
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
87 d = self._make_dict()
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
88 for (num, col) in enumerate(d):
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
89 print 'Rect %d : ' % num
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
90 for r in d[col]:
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
91 print ' (%d, %d, %d, %d)' % (r.x, r.y, r.w, r.h)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
92 print
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
93
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
94 def mouse_down(self, e):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
95 if self.mode == 'del':
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
96 pos = e.pos
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
97 cand = None
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
98 for (col, rect) in self.rects:
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
99 if rect.collidepoint(pos):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
100 cand = (col, rect)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
101 break
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
102 if cand:
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
103 self.rects.remove(cand)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
104 self.invalidate()
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
105 elif self.mode == 'draw':
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
106 self.start_pos = e.pos
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
107 self.end_pos = e.pos
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
108
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
109 def mouse_up(self, e):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
110 if self.mode == 'draw':
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
111 rect = pygame.rect.Rect(self.start_pos[0], self.start_pos[1],
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
112 self.end_pos[0] - self.start_pos[0],
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
113 self.end_pos[1] - self.start_pos[1])
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
114 rect.normalize()
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
115 self.rects.append((self.rect_color, rect))
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
116 self.start_pos = self.end_pos = None
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
117
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
118 def mouse_drag(self, e):
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
119 if self.mode == 'draw':
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
120 self.end_pos = e.pos
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
121 self.invalidate()
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
122
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
123
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
124 if __name__ == "__main__":
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
125 # FIXME: should load an actual scene with current things, not just a
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
126 # background image
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
127 pygame.display.init()
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
128 pygame.font.init()
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
129 display = pygame.display.set_mode((1000, 600))
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
130 imagefile = sys.argv[1]
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
131 app = RootWidget(display)
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
132 image = AppImage(imagefile)
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
133 app.add(image)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
134 draw = Button('Draw Rect', action=image.draw_mode)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
135 app.add(draw)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
136 draw.rect.move_ip(810, 0)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
137 delete = Button('Del Rect', action=image.del_mode)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
138 app.add(delete)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
139 delete.rect.move_ip(810, 50)
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
140 palette = AppPalette(image)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
141 palette.rect.move_ip(810, 100)
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
142 app.add(palette)
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
143 print_rects = Button("Print rects", action=image.print_rects)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
144 app.add(print_rects)
165
9b3bba5e65f3 add some features to rect helper. now vaguely useful
Neil Muller <neil@dip.sun.ac.za>
parents: 162
diff changeset
145 print_rects.rect.move_ip(810, 300)
162
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
146 quit_but = Button("Quit", action=app.quit)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
147 app.add(quit_but)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
148 quit_but.rect.move_ip(810, 500)
225e3a4b1e85 Start of a tool to help construct interact rectangles
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
149 app.run()