Mercurial > pyntnclick
comparison tools/rect_drawer.py @ 197:640044d7ddda
Tweak layout
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Thu, 26 Aug 2010 08:37:29 +0200 |
parents | b63ecd5b9a45 |
children | e73d78d6dd83 |
comparison
equal
deleted
inserted
replaced
196:b63ecd5b9a45 | 197:640044d7ddda |
---|---|
132 def mouse_drag(self, e): | 132 def mouse_drag(self, e): |
133 if self.mode == 'draw': | 133 if self.mode == 'draw': |
134 self.end_pos = e.pos | 134 self.end_pos = e.pos |
135 self.invalidate() | 135 self.invalidate() |
136 | 136 |
137 def make_button(text, action, ypos): | |
138 button = Button(text, action=action) | |
139 button.align = 'l' | |
140 button.rect = pygame.rect.Rect(0, 0, 200, 40) | |
141 button.rect.move_ip(805, ypos) | |
142 return button | |
137 | 143 |
138 if __name__ == "__main__": | 144 if __name__ == "__main__": |
139 # FIXME: should load an actual scene with current things, not just a | 145 # FIXME: should load an actual scene with current things, not just a |
140 # background image | 146 # background image |
141 if len(sys.argv) < 2: | 147 if len(sys.argv) < 2: |
152 print 'Invalid scene name' | 158 print 'Invalid scene name' |
153 sys.exit(1) | 159 sys.exit(1) |
154 app = RootWidget(display) | 160 app = RootWidget(display) |
155 image = AppImage(state) | 161 image = AppImage(state) |
156 app.add(image) | 162 app.add(image) |
157 draw = Button('Draw Rect', action=image.draw_mode) | 163 draw = make_button('Draw Rect', image.draw_mode, 0) |
158 app.add(draw) | 164 app.add(draw) |
159 draw.rect.move_ip(810, 0) | 165 delete = make_button('Del Rect', image.del_mode, 40) |
160 delete = Button('Del Rect', action=image.del_mode) | |
161 app.add(delete) | 166 app.add(delete) |
162 delete.rect.move_ip(810, 50) | |
163 palette = AppPalette(image) | 167 palette = AppPalette(image) |
164 palette.rect.move_ip(810, 100) | 168 palette.rect.move_ip(810, 80) |
165 app.add(palette) | 169 app.add(palette) |
166 print_rects = Button("Print rects", action=image.print_rects) | 170 print_rects = make_button("Print rects", image.print_rects, 240) |
167 app.add(print_rects) | 171 app.add(print_rects) |
168 print_rects.rect.move_ip(810, 300) | 172 quit_but = make_button("Quit", app.quit, 560) |
169 quit_but = Button("Quit", action=app.quit) | |
170 app.add(quit_but) | 173 app.add(quit_but) |
171 quit_but.rect.move_ip(810, 500) | |
172 app.run() | 174 app.run() |