def draw(self, subset, context): ''' Return a list of panels to be displayed to the user for evaluation. Use the arg parentPanel as the parent for each of the panels created. ''' temp_app = wxApp() folder = context.get('path', '') panels = [] i = 0 for ind in subset: if ind.shape_list: filename = '%s_ind_%d.jpeg' % (folder, i) # draw shapes which are bigger than a threshold shape_list = deepcopy(ind.shape_list) # sort so that smaller shapes are drawn on top of bigger shapes shape_list.sort(lambda a, b: -cmp(a.getArea(), b.getArea())) doc = docpanel.DocPanel(self.params, individual = ind, quad_tree = shape_list, color_scheme = ind.color, name = filename) panels.append(filename) i += 1 del temp_app return panels
def run(self, installSignalHandlers=True): """ Start the reactor. """ self._postQueue = Queue.Queue() if not hasattr(self, "wxapp"): log.msg("registerWxApp() was not called on reactor, " "registering my own wxApp instance.") self.registerWxApp(wxApp(False)) # start select() thread: self.interleave(self._runInMainThread, installSignalHandlers=installSignalHandlers) if installSignalHandlers: self.callLater(0, self._installSignalHandlersAgain) # add cleanup events: self.addSystemEventTrigger("after", "shutdown", self._stopWx) self.addSystemEventTrigger("after", "shutdown", lambda: self._postQueue.put(None)) # On Mac OS X, work around wx bug by starting timer to ensure # wxCallAfter calls are always processed. We don't wake up as # often as we could since that uses too much CPU. if runtime.platform.isMacOSX(): t = ProcessEventsTimer(self.wxapp) t.Start(2) # wake up every 2ms self.wxapp.MainLoop() wxapp = self.wxapp del self.wxapp if not self._stopping: # wx event loop exited without reactor.stop() being # called. At this point events from select() thread will # be added to _postQueue, but some may still be waiting # unprocessed in wx, thus the ProcessPendingEvents() # below. self.stop() wxapp.ProcessPendingEvents() # deal with any queued wxCallAfters while 1: try: f = self._postQueue.get(timeout=0.01) except Queue.Empty: continue else: if f is None: break try: f() except: log.err()