def ShowDialogImportOtherFiles(self, id_type): # Offer to save current project if necessary session = ses.Session() st = session.project_status if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): filename = session.project_path[1] answer = dialog.SaveChangesDialog2(filename) if answer: self.ShowDialogSaveProject() self.CloseProject() # Publisher.sendMessage("Enable state project", False) Publisher.sendMessage('Set project name') Publisher.sendMessage("Stop Config Recording") Publisher.sendMessage("Set slice interaction style", const.STATE_DEFAULT) # Warning for limited support to Analyze format if id_type == const.ID_ANALYZE_IMPORT: dialog.ImportAnalyzeWarning() # Import project treating compressed nifti exception suptype = ('hdr', 'nii', 'nii.gz', 'par') filepath = dialog.ShowImportOtherFilesDialog(id_type) if filepath is not None: name = filepath.rpartition('\\')[-1].split('.') if name[-1] == 'gz': name[1] = 'nii.gz' filetype = name[1].lower() if filetype in suptype: Publisher.sendMessage("Open other files", filepath) else: dialog.ImportInvalidFiles()
def OnOpenRecentProject(self, filepath): if os.path.exists(filepath): session = ses.Session() st = session.project_status if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): filename = session.project_path[1] answer = dialog.SaveChangesDialog2(filename) if answer: self.ShowDialogSaveProject() if session.IsOpen(): self.CloseProject() self.OpenProject(filepath) else: dialog.InexistentPath(filepath)
def ShowDialogOpenProject(self): # Offer to save current project if necessary session = ses.Session() st = session.project_status if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): filename = session.project_path[1] answer = dialog.SaveChangesDialog2(filename) if answer: self.ShowDialogSaveProject() # Open project filepath = dialog.ShowOpenProjectDialog() if filepath: if session.IsOpen(): self.CloseProject() self.OpenProject(filepath)
def ShowDialogImportDirectory(self): # Offer to save current project if necessary session = ses.Session() st = session.project_status if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): filename = session.project_path[1] answer = dialog.SaveChangesDialog2(filename) if answer: self.ShowDialogSaveProject() self.CloseProject() #Publisher.sendMessage("Enable state project", state=False) Publisher.sendMessage('Set project name') Publisher.sendMessage("Stop Config Recording") Publisher.sendMessage("Enable style", style=const.STATE_DEFAULT) # Import project dirpath = dialog.ShowImportDirDialog(self.frame) if dirpath and not os.listdir(dirpath): dialog.ImportEmptyDirectory(dirpath) elif dirpath: self.StartImportPanel(dirpath)
def ShowDialogImportOtherFiles(self, id_type): # Offer to save current project if necessary session = ses.Session() st = session.project_status if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): filename = session.project_path[1] answer = dialog.SaveChangesDialog2(filename) if answer: self.ShowDialogSaveProject() self.CloseProject() # Publisher.sendMessage("Enable state project", state=False) Publisher.sendMessage('Set project name') Publisher.sendMessage("Stop Config Recording") Publisher.sendMessage("Enable style", style=const.STATE_DEFAULT) # Warning for limited support to Analyze format if id_type == const.ID_ANALYZE_IMPORT: dialog.ImportAnalyzeWarning() filepath = dialog.ShowImportOtherFilesDialog(id_type) Publisher.sendMessage("Open other files", filepath=filepath)