The user clicked the "Import Stack Files" button.
// Find the directory of the most recently opened image filemostRecentStackImageFile = PreferencesManager().get( "DataSelection", "recent stack image" )if mostRecentStackImageFile is not None:
defaultDirectory = os.path.split(mostRecentStackImageFile)[0]
else:
defaultDirectory = os.path.expanduser("~")
// Launch the "Open File" dialog
fileNames = self.getImageFileNamesToOpen(defaultDirectory)
iflen(fileNames)== 1:
QMessageBox.warning(self, "Invalid selection", "Cannot create stack: You only selected one file. If your stack is contained in a single file (e.g. a multi-page tiff or hdf5 volume), please use the "Add File" button." )
return
After Change
stackDlg = StackFileSelectionWidget(self)
stackDlg.exec_()
if stackDlg.result() != QDialog.Accepted :
return files = stackDlg.selectedFiles
iflen(files)== 0:
returninfo = DatasetInfo()
info.filePath = "//".join( files )
// Allow labels by default if this gui isn"t being used for batch data.
info.allowLabels = ( self.guiMode == GuiMode.Normal )
laneIndex = self._findFirstEmptyLane(roleIndex)
iflen(self.topLevelOperator.DatasetGroup) < laneIndex+1:
self.topLevelOperator.DatasetGroup.resize(laneIndex+1)
def importStack():
self.guiControlSignal.emit( ControlCommand.DisableAll )// Serializer will update the operator for us, which will propagate to the GUI.try:
self.serializer.importStackAsLocalDataset( info )
self.topLevelOperator.DatasetGroup[laneIndex][roleIndex].setValue(info)finally:
self.guiControlSignal.emit( ControlCommand.Pop )
req = Request( importStack )
req.notify_failed( partial(self.handleFailedStackLoad, files ) )
req.submit()
@threadRouted