How to use the slicer.util.errorDisplay function in slicer

To help you get started, we’ve selected a few slicer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QIICR / SlicerDevelopmentToolbox / SlicerDevelopmentToolboxUtils / helpers.py View on Github external
def onStateChanged(self, newState):
    stdout, stderr = super(DICOMDirectorySender, self).onStateChanged(newState)
    if stderr and stderr.size():
      slicer.util.errorDisplay("An error occurred. For further information click 'Show Details...'",
                               windowTitle=self.__class__.__name__, detailedText=str(stderr))
    return stdout, stderr
github faustomilletari / TOMAAT-Slicer / TOMAAT / TOMAAT.py View on Github external
if "fingerprint" in result.keys():
                # untrusted host -> ask to add to keystore
                if slicer.util.confirmYesNoDisplay(
                        "{}\nDo you want to consider the following data as trusted in the future:\n{}".format(result['msg'], str(
                            result['fingerprint']))
                ):
                    host, port, fprint = result['fingerprint']
                    # write to SSLUtil
                    SSLUtil.fingerprintsLocal.update({fprint: {"port": port, "host": host}})
                    logic.writeFingerprintFile()
                    return True
                return False

            else:
                # no connection to host
                slicer.util.errorDisplay(result["msg"])
                return False
        return True
github SlicerDMRI / SlicerDMRI / Modules / Scripted / TractographyDownsample / TractographyDownsample.py View on Github external
def run(self, inputFiberBundle, outputFiberBundle, fiberStepSize, fiberPercentage, fiberMinPoints, fiberMinLength, fiberMaxLength, enableScreenshots=0, advanced=0):
    """
    Run the actual algorithm
    """

    if not advanced:
      if not self.isValidInputOutputData(inputFiberBundle, outputFiberBundle):
        slicer.util.errorDisplay('Input fiberBundle is the same as output fiberBundle. Choose a different output fiberBundle.')
        return False

    logging.info('Processing started')

    # Compute the thresholded output fiberBundle using the Threshold Scalar FiberBundle CLI module
    #cliParams = {'InputFiberBundle': inputFiberBundle.GetID(), 'OutputFiberBundle': outputFiberBundle.GetID(), 'ThresholdValue' : fiberStepSize, 'ThresholdType' : 'Above'}
    #cliNode = slicer.cli.run(slicer.modules.thresholdscalarfiberBundle, None, cliParams, wait_for_completion=True)

    # access input data object
    pd = inputFiberBundle.GetPolyData()
    # create a new polydata to hold the output
    outpd = vtk.vtkPolyData()

    # log information about input
    logging.info('Input Fiber Bundle Stats:')
    logging.info(inputFiberBundle.GetName())
github SlicerProstate / SliceTracker / SliceTracker / SliceTrackerUtils / steps / plugins / training.py View on Github external
def unzipFileAndCopyToDirectory(self, filepath, copyToDirectory):
    import zipfile
    try:
      zip_ref = zipfile.ZipFile(filepath, 'r')
      destination = filepath.replace(os.path.basename(filepath), "")
      logging.debug("extracting to %s " % destination)
      zip_ref.extractall(destination)
      zip_ref.close()
      self.copyDirectory(filepath.replace(".zip", ""), copyToDirectory)
    except zipfile.BadZipfile as exc:
      if self.session.preopDICOMReceiver:
        self.session.preopDICOMReceiver.hide()
      slicer.util.errorDisplay("An error appeared while extracting %s. If the file is corrupt, please delete it and try "
                               "again." % filepath, detailedText=str(exc.message))
      self.clearData()