diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 517714104d1cb62f3b0c03c34843595d85502417..d4c4396cd159032faaae4438dffc8562693ad5f6 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -63,6 +63,7 @@ class MainWindow(QMainWindow): def __init__(self, lang="ch", gpu=False, + kei_mode=False, default_filename=None, default_predefined_class_file=None, default_save_dir=None): @@ -76,6 +77,7 @@ class MainWindow(QMainWindow): self.settings.load() settings = self.settings self.lang = lang + self.kie_mode = kei_mode # Load string bundle for i18n if lang not in ['ch', 'en']: lang = 'en' @@ -133,11 +135,13 @@ class MainWindow(QMainWindow): self.autoSaveNum = 5 # ================== File List ================== + + filelistLayout = QVBoxLayout() + filelistLayout.setContentsMargins(0, 0, 0, 0) + self.fileListWidget = QListWidget() self.fileListWidget.itemClicked.connect(self.fileitemDoubleClicked) self.fileListWidget.setIconSize(QSize(25, 25)) - filelistLayout = QVBoxLayout() - filelistLayout.setContentsMargins(0, 0, 0, 0) filelistLayout.addWidget(self.fileListWidget) self.AutoRecognition = QToolButton() @@ -158,10 +162,26 @@ class MainWindow(QMainWindow): self.fileDock.setWidget(fileListContainer) self.addDockWidget(Qt.LeftDockWidgetArea, self.fileDock) + # ================== Key List ================== + if self.kie_mode: + self.keyList = QListWidget() + + # self.keyList.itemActivated.connect(self.boxSelectionChanged) + self.keyList.itemSelectionChanged.connect(self.keyListSelectionChanged) + self.keyList.itemDoubleClicked.connect(self.editBox) + # Connect to itemChanged to detect checkbox changes. + self.keyList.itemChanged.connect(self.keyListItemChanged) + self.keyListDockName = getStr('keyListTitle') + self.keyListDock = QDockWidget(self.keyListDockName, self) + self.keyListDock.setWidget(self.keyList) + self.keyListDock.setFeatures(QDockWidget.NoDockWidgetFeatures) + filelistLayout.addWidget(self.keyListDock) + # ================== Right Area ================== listLayout = QVBoxLayout() listLayout.setContentsMargins(0, 0, 0, 0) + # Buttons self.editButton = QToolButton() self.reRecogButton = QToolButton() self.reRecogButton.setIcon(newIcon('reRec', 30)) @@ -174,12 +194,12 @@ class MainWindow(QMainWindow): self.DelButton = QToolButton() self.DelButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) - lefttoptoolbox = QHBoxLayout() - lefttoptoolbox.addWidget(self.newButton) - lefttoptoolbox.addWidget(self.reRecogButton) - lefttoptoolboxcontainer = QWidget() - lefttoptoolboxcontainer.setLayout(lefttoptoolbox) - listLayout.addWidget(lefttoptoolboxcontainer) + leftTopToolBox = QHBoxLayout() + leftTopToolBox.addWidget(self.newButton) + leftTopToolBox.addWidget(self.reRecogButton) + leftTopToolBoxContainer = QWidget() + leftTopToolBoxContainer.setLayout(leftTopToolBox) + listLayout.addWidget(leftTopToolBoxContainer) # ================== Label List ================== # Create and add a widget for showing current label items @@ -1114,6 +1134,12 @@ class MainWindow(QMainWindow): else: self.canvas.deSelectShape() + def keyListSelectionChanged(self): + pass + + def keyListItemChanged(self): + pass + def boxSelectionChanged(self): if self._noSelectionSlot: # self.BoxList.scrollToItem(self.currentBox(), QAbstractItemView.PositionAtCenter) @@ -2177,8 +2203,9 @@ def get_main_app(argv=[]): app.setWindowIcon(newIcon("app")) # Tzutalin 201705+: Accept extra arguments to change predefined class file arg_parser = argparse.ArgumentParser() - arg_parser.add_argument("--lang", type=str, default='en', nargs="?") + arg_parser.add_argument("--lang", type=str, default='ch', nargs="?") arg_parser.add_argument("--gpu", type=str2bool, default=True, nargs="?") + arg_parser.add_argument("--kie", type=str2bool, default=True, nargs="?") arg_parser.add_argument("--predefined_classes_file", default=os.path.join(os.path.dirname(__file__), "data", "predefined_classes.txt"), nargs="?") @@ -2186,6 +2213,7 @@ def get_main_app(argv=[]): win = MainWindow(lang=args.lang, gpu=args.gpu, + kei_mode=args.kie, default_predefined_class_file=args.predefined_classes_file) win.show() return app, win diff --git a/PPOCRLabel/resources/strings/strings-en.properties b/PPOCRLabel/resources/strings/strings-en.properties index f59e43aa92ff9ccd04686e9c16db181983b57b2c..eee25ec1af36c796e97af252b53e0e9948cc1444 100644 --- a/PPOCRLabel/resources/strings/strings-en.properties +++ b/PPOCRLabel/resources/strings/strings-en.properties @@ -106,4 +106,5 @@ undo=Undo undoLastPoint=Undo Last Point autoSaveMode=Auto Export Label Mode lockBox=Lock selected box/Unlock all box -lockBoxDetail=Lock selected box/Unlock all box \ No newline at end of file +lockBoxDetail=Lock selected box/Unlock all box +keyListTitle=Key List \ No newline at end of file diff --git a/PPOCRLabel/resources/strings/strings-zh-CN.properties b/PPOCRLabel/resources/strings/strings-zh-CN.properties index d8bd9d4bff02748397d7a57a6205e67ff69779c2..bb411bfdb37a1b8dd5b59cca4a556f67f3a95dfa 100644 --- a/PPOCRLabel/resources/strings/strings-zh-CN.properties +++ b/PPOCRLabel/resources/strings/strings-zh-CN.properties @@ -107,3 +107,4 @@ undoLastPoint=撤销上个点 autoSaveMode=自动导出标记结果 lockBox=锁定框/解除锁定框 lockBoxDetail=若当前没有框处于锁定状态则锁定选中的框,若存在锁定框则解除所有锁定框的锁定状态 +keyListTitle=关键词列表 \ No newline at end of file