diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 9ffa909e98f9c4c6156b8cae0675ef8aa5141620..79c145d156323847b5b1ecd5b9c3d328e9b9bfc4 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -360,6 +360,9 @@ class MainWindow(QMainWindow, WindowMixin): opendir = action(getStr('openDir'), self.openDirDialog, 'Ctrl+u', 'open', getStr('openDir')) + open_dataset_dir = action(getStr('openDatasetDir'), self.openDatasetDirDialog, + 'Ctrl+p', 'open', getStr('openDatasetDir'), enabled=False) + save = action(getStr('save'), self.saveFile, 'Ctrl+V', 'verify', getStr('saveDetail'), enabled=False) @@ -519,9 +522,9 @@ class MainWindow(QMainWindow, WindowMixin): zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg, fitWindow=fitWindow, fitWidth=fitWidth, zoomActions=zoomActions, saveLabel=saveLabel, - undo=undo, undoLastPoint=undoLastPoint, + undo=undo, undoLastPoint=undoLastPoint,open_dataset_dir=open_dataset_dir, fileMenuActions=( - opendir, saveLabel, resetAll, quit), + opendir, open_dataset_dir, saveLabel, resetAll, quit), beginner=(), advanced=(), editMenu=(createpoly, edit, copy, delete,singleRere,None, undo, undoLastPoint, None, color1, self.drawSquaresOption), @@ -563,7 +566,7 @@ class MainWindow(QMainWindow, WindowMixin): self.autoSaveOption.triggered.connect(self.autoSaveFunc) addActions(self.menus.file, - (opendir, None, saveLabel, saveRec, self.autoSaveOption, None, resetAll, deleteImg, quit)) + (opendir, open_dataset_dir, None, saveLabel, saveRec, self.autoSaveOption, None, resetAll, deleteImg, quit)) addActions(self.menus.help, (showSteps, showInfo)) addActions(self.menus.view, ( @@ -1448,6 +1451,23 @@ class MainWindow(QMainWindow, WindowMixin): self.lastOpenDir = targetDirPath self.importDirImages(targetDirPath) + def openDatasetDirDialog(self, _value=False): #1458 + if not self.mayContinue(): + return + + if self.lastOpenDir and os.path.exists(self.lastOpenDir): + os.startfile(self.lastOpenDir) + defaultOpenDirPath = self.lastOpenDir + else: + if self.lang == 'ch': + self.actions.open_dataset_dir.setEnabled(False) + self.msgBox.warning(self, "提示", "\n 原文件夹已不存在,请从新选择数据集路径!") + defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.' + else: + self.actions.open_dataset_dir.setEnabled (False) + self.msgBox.warning (self, "Warn", "\n The original folder no longer exists, please choose the data set path again!") + defaultOpenDirPath = os.path.dirname (self.filePath) if self.filePath else '.' + def importDirImages(self, dirpath, isDelete = False): if not self.mayContinue() or not dirpath: return @@ -1495,6 +1515,7 @@ class MainWindow(QMainWindow, WindowMixin): self.reRecogButton.setEnabled(True) self.actions.AutoRec.setEnabled(True) self.actions.reRec.setEnabled(True) + self.actions.open_dataset_dir.setEnabled(True) def openPrevImg(self, _value=False): diff --git a/PPOCRLabel/resources/strings/strings-zh-CN.properties b/PPOCRLabel/resources/strings/strings-zh-CN.properties index 207f63d286c4097afaa2b1e5b5bfc0dbd9e9917f..f246c8febedd625535814831fba655fa8c27ab59 100644 --- a/PPOCRLabel/resources/strings/strings-zh-CN.properties +++ b/PPOCRLabel/resources/strings/strings-zh-CN.properties @@ -31,6 +31,7 @@ save=确认 saveAs=另存为 fitWinDetail=缩放到当前窗口大小 openDir=打开目录 +openDatasetDir=打开数据集路径 copyPrevBounding=复制当前图像中的上一个边界框 showHide=显示/隐藏标签 changeSaveFormat=更改存储格式 diff --git a/PPOCRLabel/resources/strings/strings.properties b/PPOCRLabel/resources/strings/strings.properties index 321b1c65a1687e7fc22f78496cd2dc4a524a2e26..55baea07423495baffa91f22db74b3ee3f985e9f 100644 --- a/PPOCRLabel/resources/strings/strings.properties +++ b/PPOCRLabel/resources/strings/strings.properties @@ -3,6 +3,7 @@ openFileDetail=Open image or label file quit=Quit quitApp=Quit application openDir=Open Dir +openDatasetDir=open DatasetDir copyPrevBounding=Copy previous Bounding Boxes in the current image changeSavedAnnotationDir=Change default saved Annotation dir openAnnotation=Open Annotation