comparison pyntnclick/tools/rect_drawer.py @ 718:ab489f7e87f8 pyntnclick

Make filechooser widget presistent, to avoid constantly descending directory trees
author Neil Muller <neil@dip.sun.ac.za>
date Mon, 06 Aug 2012 11:17:27 +0200
parents 3b2d1adca59c
children 3aa6163f0775
comparison
equal deleted inserted replaced
717:3b2d1adca59c 718:ab489f7e87f8
134 self.old_mouse_pos = None 134 self.old_mouse_pos = None
135 self.zoom_display = False 135 self.zoom_display = False
136 self.draw_anim = False 136 self.draw_anim = False
137 self.zoom_offset = (600, 600) 137 self.zoom_offset = (600, 600)
138 self.clear_display = False 138 self.clear_display = False
139 self.filechooser = None
139 if self._detail: 140 if self._detail:
140 w, h = self._scene.get_detail_size() 141 w, h = self._scene.get_detail_size()
141 rect = pygame.rect.Rect(0, 0, w, h) 142 rect = pygame.rect.Rect(0, 0, w, h)
142 self.close_button.rect.midbottom = rect.midbottom 143 self.close_button.rect.midbottom = rect.midbottom
143 self.offset = (0, 0) 144 self.offset = (0, 0)
345 print ' (%d, %d, %d, %d),' % (r.x, r.y, r.w, r.h) 346 print ' (%d, %d, %d, %d),' % (r.x, r.y, r.w, r.h)
346 print 347 print
347 print 348 print
348 349
349 def image_load(self, ev, widget): 350 def image_load(self, ev, widget):
350 filechooser = FileChooser((0, 0), self.gd, os.curdir, 351 if self.filechooser is None:
351 self.do_load_image) 352 self.filechooser = FileChooser((0, 0), self.gd, os.curdir,
352 self._parent.add(filechooser) 353 self.do_load_image)
354 else:
355 self.filechooser.refresh()
356 self.invalidate()
357 self._parent.add(self.filechooser)
353 358
354 def do_load_image(self, filename): 359 def do_load_image(self, filename):
355 try: 360 try:
356 self.current_image = TranslucentImage((0, 0), self.gd, 361 self.current_image = TranslucentImage((0, 0), self.gd,
357 pygame.image.load(filename)) 362 pygame.image.load(filename))