Example #1
0
    def event(self, e):
        if e.type() == 9999:
            return QDialog.event(self, QCloseEvent())

        if e.type() == 9998:
            return QDialog.event(self, QCloseEvent())
        if e.type() == QEvent.Close:
            e.ignore()
            return True

        return QDialog.event(self, e)
Example #2
0
 def event(self, event):
     if isinstance(event, NextImageGrowthEvent):
         self.progress.setValue(self.progress.value()+1)
         return True
     elif isinstance(event, FinishImageGrowthEvent):
         self.progress.reset()
         del self.thread
         del self.progress
         QMessageBox.information(self, "Growth computation", "The growth has been correctly computed and saved")
         #QDialog.accept(self)
         return True
     elif isinstance(event, AbortImageGrowthEvent):
         self.progress.reset()
         del self.thread
         del self.progress
         QMessageBox.information(self, "Growth computation", "The growth computation has been aborted.\nNothing was saved.")
         return True
     return QDialog.event(self, event)
Example #3
0
 def event(self, event):
     if event.type() == NextImageEvent.event_type:
         self.progress.setValue(self.progress.value()+1)
         return True
     elif event.type() == AbortPlottingEvent.event_type:
         if parameters.instance.use_thread:
             self.progress.cancel()
             self.thread.wait()
             del self.progress
         if self.thread.loading:
             QMessageBox.critical(self, "Invalid file", "File %s could not be loaded.\nError: '%s'" 
                     % (self.thread.result, str(event.reason)))
             self.has_cells = False
             self.has_walls = False
             self.has_points = False
             self.enableControls(False)
             self.apply_button.setEnabled(False)
             self.setEnabled(True)
             self.updateInterface()
         else:
             QMessageBox.critical(self, "Error during plot rendering", "The plotting was aborted for the following reason: %s" % event.reason)
         return True
     elif event.type() == FinishPlottingEvent.event_type:
         self.progress.reset()
         self.thread.wait()
         self.progress.close()
         del self.progress
         QMessageBox.information(self, "Plot rendering", "The rendering is finished.")
         return True
     elif event.type() == FinishLoadingEvent.event_type:
         if self.thread.retryObject is not None:
             msg = self.thread.retryObject.question
             answer = QMessageBox.question(self, "Error loading data file", msg, buttons=QMessageBox.Yes | QMessageBox.No)
             if answer == QMessageBox.No:
                 self.ui.growthFile.setText("")
                 self.progress.reset()
                 del self.progress
                 self.has_cells = False
                 self.has_walls = False
                 self.has_points = False
                 self.enableControls(False)
                 self.apply_button.setEnabled(False)
                 self.setEnabled(True)
                 self.updateInterface()
             else:
                 self.thread.reload()
         else:
             self.progress.reset()
             self.thread.wait()
             del self.progress
             self.setEnabled(True)
             self.load_results()
             self.updateInterface()
             log_debug("Loading thread finished. Plotting window enabled again.")
         return True
     elif event.type() == ImageReadyPlottingEvent.event_type:
         self.thread.wait()
         if self.preview is not None:
             self.preview.pic_w = self.thread.pic_w
             self.preview.pic_c = self.thread.pic_c
             self.preview.pix = self.thread.pix
     elif event.type() == UpdateNbImageEvent.event_type:
         nb = event.nb
         log_debug("Number of events to process: %d" % nb)
         self.progress.setMaximum(nb)
     return QDialog.event(self, event)
Example #4
0
 def event(self, event):
     if event.type() == NextImageEvent.event_type:
         self.progress.setValue(self.progress.value() + 1)
         return True
     elif event.type() == AbortPlottingEvent.event_type:
         if parameters.instance.use_thread:
             self.progress.cancel()
             self.thread.wait()
             del self.progress
         if self.thread.loading:
             QMessageBox.critical(
                 self, "Invalid file",
                 "File %s could not be loaded.\nError: '%s'" %
                 (self.thread.result, str(event.reason)))
             self.has_cells = False
             self.has_walls = False
             self.has_points = False
             self.enableControls(False)
             self.apply_button.setEnabled(False)
             self.setEnabled(True)
             self.updateInterface()
         else:
             QMessageBox.critical(
                 self, "Error during plot rendering",
                 "The plotting was aborted for the following reason: %s" %
                 event.reason)
         return True
     elif event.type() == FinishPlottingEvent.event_type:
         self.progress.reset()
         self.thread.wait()
         self.progress.close()
         del self.progress
         QMessageBox.information(self, "Plot rendering",
                                 "The rendering is finished.")
         return True
     elif event.type() == FinishLoadingEvent.event_type:
         if self.thread.retryObject is not None:
             msg = self.thread.retryObject.question
             answer = QMessageBox.question(self,
                                           "Error loading data file",
                                           msg,
                                           buttons=QMessageBox.Yes
                                           | QMessageBox.No)
             if answer == QMessageBox.No:
                 self.ui.growthFile.setText("")
                 self.progress.reset()
                 del self.progress
                 self.has_cells = False
                 self.has_walls = False
                 self.has_points = False
                 self.enableControls(False)
                 self.apply_button.setEnabled(False)
                 self.setEnabled(True)
                 self.updateInterface()
             else:
                 self.thread.reload()
         else:
             self.progress.reset()
             self.thread.wait()
             del self.progress
             self.setEnabled(True)
             self.load_results()
             self.updateInterface()
             log_debug(
                 "Loading thread finished. Plotting window enabled again.")
         return True
     elif event.type() == ImageReadyPlottingEvent.event_type:
         self.thread.wait()
         if self.preview is not None:
             self.preview.pic_w = self.thread.pic_w
             self.preview.pic_c = self.thread.pic_c
             self.preview.pix = self.thread.pix
     elif event.type() == UpdateNbImageEvent.event_type:
         nb = event.nb
         log_debug("Number of events to process: %d" % nb)
         self.progress.setMaximum(nb)
     return QDialog.event(self, event)