def _update_processing(self, event): while True: try: new_message = self.message_queue.get_nowait() except Queue.Empty: new_message = None if new_message is not None: statement, data = new_message if statement == 'TASKS': self._num_tasks = len(data) self._update_messages('Created %d tasks.' % len(data)) if statement == 'SKIPPED_TASK': self._num_tasks_competed += 1 self._update_messages('Skipped %s' % data) if statement == 'IMPOSSIBLE_TASK': self._num_tasks_competed += 1 self._update_messages('Removed %s\n Reason: task was impossible to complete.' % data) if statement == 'RUNNING_TASK': self._update_messages('Started %s' % data) if statement == 'TASK_ERROR': self._update_messages('ERROR on %s:\n\n %s' % (data['task'], wrap(data['traceback'], 80))) self._num_tasks_competed = self._num_tasks self.close_button.SetLabel('ABORT') self.info_text.SetLabel('An ERROR occured in a plugin!') if statement == 'FINISHED_TASK': self._num_tasks_competed += 1 self._update_messages( 'Finished %s\n Runtime:%8.4f seconds' % (data['task'], data['runtime'])) self._plugin_runtime += data['runtime'] if statement == 'DISPLAY_GRAPH': plot_dict = data self.graph_area.add_plot_data(plot_dict) progress = int((self._num_tasks_competed/ float(self._num_tasks))*100.0) self.gauge.SetValue(progress) else: break progress = int((self._num_tasks_competed/ float(self._num_tasks))*100.0) if progress >= 100: if self._just_once: self._just_once = False self.close_button.Enable() if 'ERROR' not in self.info_text.GetLabel(): self.info_text.SetLabel('Finished Processing') total_runtime = time.time()-self._start_time self._update_messages('Finished Processing:\n Total Runtime = %f seconds (real time)\n Time spent in plugins = %f seconds (cpu time, not real time)' % (total_runtime, self._plugin_runtime)) else: self._spin() self._draw_messages()
def layout_ui(self): label = wrap(self.plugin.name, 40) active_checkbox = wx.CheckBox(self, label=label) f = active_checkbox.GetFont() if wx.Platform == '__WXMSW__' and len(label) > 40: f.SetPointSize(f.GetPointSize()-2) f.SetWeight(wx.BOLD) active_checkbox.SetFont(f) active_checkbox.SetValue(True) self.Bind(wx.EVT_CHECKBOX, self._activate, active_checkbox) sizer = wx.BoxSizer(orient=wx.VERTICAL) sizer.Add(active_checkbox, flag=wx.ALIGN_LEFT) for ctrl_name in sorted(self.ctrls.keys()): sizer.Add(self.ctrls[ctrl_name], flag=wx.EXPAND|wx.ALIGN_RIGHT) self.ctrls[ctrl_name].register_valid_entry_callback( self.valid_entry_callback) sizer.Add(wx.StaticLine(self), flag=wx.EXPAND|wx.ALL, border=3) self.SetSizer(sizer) self.active_checkbox = active_checkbox