提交 89c9abf6 编写于 作者: HinGwenWoong's avatar HinGwenWoong

UI add key list

上级 b5c7163e
...@@ -63,6 +63,7 @@ class MainWindow(QMainWindow): ...@@ -63,6 +63,7 @@ class MainWindow(QMainWindow):
def __init__(self, def __init__(self,
lang="ch", lang="ch",
gpu=False, gpu=False,
kei_mode=False,
default_filename=None, default_filename=None,
default_predefined_class_file=None, default_predefined_class_file=None,
default_save_dir=None): default_save_dir=None):
...@@ -76,6 +77,7 @@ class MainWindow(QMainWindow): ...@@ -76,6 +77,7 @@ class MainWindow(QMainWindow):
self.settings.load() self.settings.load()
settings = self.settings settings = self.settings
self.lang = lang self.lang = lang
self.kie_mode = kei_mode
# Load string bundle for i18n # Load string bundle for i18n
if lang not in ['ch', 'en']: if lang not in ['ch', 'en']:
lang = 'en' lang = 'en'
...@@ -133,11 +135,13 @@ class MainWindow(QMainWindow): ...@@ -133,11 +135,13 @@ class MainWindow(QMainWindow):
self.autoSaveNum = 5 self.autoSaveNum = 5
# ================== File List ================== # ================== File List ==================
filelistLayout = QVBoxLayout()
filelistLayout.setContentsMargins(0, 0, 0, 0)
self.fileListWidget = QListWidget() self.fileListWidget = QListWidget()
self.fileListWidget.itemClicked.connect(self.fileitemDoubleClicked) self.fileListWidget.itemClicked.connect(self.fileitemDoubleClicked)
self.fileListWidget.setIconSize(QSize(25, 25)) self.fileListWidget.setIconSize(QSize(25, 25))
filelistLayout = QVBoxLayout()
filelistLayout.setContentsMargins(0, 0, 0, 0)
filelistLayout.addWidget(self.fileListWidget) filelistLayout.addWidget(self.fileListWidget)
self.AutoRecognition = QToolButton() self.AutoRecognition = QToolButton()
...@@ -158,10 +162,26 @@ class MainWindow(QMainWindow): ...@@ -158,10 +162,26 @@ class MainWindow(QMainWindow):
self.fileDock.setWidget(fileListContainer) self.fileDock.setWidget(fileListContainer)
self.addDockWidget(Qt.LeftDockWidgetArea, self.fileDock) 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 ================== # ================== Right Area ==================
listLayout = QVBoxLayout() listLayout = QVBoxLayout()
listLayout.setContentsMargins(0, 0, 0, 0) listLayout.setContentsMargins(0, 0, 0, 0)
# Buttons
self.editButton = QToolButton() self.editButton = QToolButton()
self.reRecogButton = QToolButton() self.reRecogButton = QToolButton()
self.reRecogButton.setIcon(newIcon('reRec', 30)) self.reRecogButton.setIcon(newIcon('reRec', 30))
...@@ -174,12 +194,12 @@ class MainWindow(QMainWindow): ...@@ -174,12 +194,12 @@ class MainWindow(QMainWindow):
self.DelButton = QToolButton() self.DelButton = QToolButton()
self.DelButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.DelButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
lefttoptoolbox = QHBoxLayout() leftTopToolBox = QHBoxLayout()
lefttoptoolbox.addWidget(self.newButton) leftTopToolBox.addWidget(self.newButton)
lefttoptoolbox.addWidget(self.reRecogButton) leftTopToolBox.addWidget(self.reRecogButton)
lefttoptoolboxcontainer = QWidget() leftTopToolBoxContainer = QWidget()
lefttoptoolboxcontainer.setLayout(lefttoptoolbox) leftTopToolBoxContainer.setLayout(leftTopToolBox)
listLayout.addWidget(lefttoptoolboxcontainer) listLayout.addWidget(leftTopToolBoxContainer)
# ================== Label List ================== # ================== Label List ==================
# Create and add a widget for showing current label items # Create and add a widget for showing current label items
...@@ -1114,6 +1134,12 @@ class MainWindow(QMainWindow): ...@@ -1114,6 +1134,12 @@ class MainWindow(QMainWindow):
else: else:
self.canvas.deSelectShape() self.canvas.deSelectShape()
def keyListSelectionChanged(self):
pass
def keyListItemChanged(self):
pass
def boxSelectionChanged(self): def boxSelectionChanged(self):
if self._noSelectionSlot: if self._noSelectionSlot:
# self.BoxList.scrollToItem(self.currentBox(), QAbstractItemView.PositionAtCenter) # self.BoxList.scrollToItem(self.currentBox(), QAbstractItemView.PositionAtCenter)
...@@ -2177,8 +2203,9 @@ def get_main_app(argv=[]): ...@@ -2177,8 +2203,9 @@ def get_main_app(argv=[]):
app.setWindowIcon(newIcon("app")) app.setWindowIcon(newIcon("app"))
# Tzutalin 201705+: Accept extra arguments to change predefined class file # Tzutalin 201705+: Accept extra arguments to change predefined class file
arg_parser = argparse.ArgumentParser() 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("--gpu", type=str2bool, default=True, nargs="?")
arg_parser.add_argument("--kie", type=str2bool, default=True, nargs="?")
arg_parser.add_argument("--predefined_classes_file", arg_parser.add_argument("--predefined_classes_file",
default=os.path.join(os.path.dirname(__file__), "data", "predefined_classes.txt"), default=os.path.join(os.path.dirname(__file__), "data", "predefined_classes.txt"),
nargs="?") nargs="?")
...@@ -2186,6 +2213,7 @@ def get_main_app(argv=[]): ...@@ -2186,6 +2213,7 @@ def get_main_app(argv=[]):
win = MainWindow(lang=args.lang, win = MainWindow(lang=args.lang,
gpu=args.gpu, gpu=args.gpu,
kei_mode=args.kie,
default_predefined_class_file=args.predefined_classes_file) default_predefined_class_file=args.predefined_classes_file)
win.show() win.show()
return app, win return app, win
......
...@@ -107,3 +107,4 @@ undoLastPoint=Undo Last Point ...@@ -107,3 +107,4 @@ undoLastPoint=Undo Last Point
autoSaveMode=Auto Export Label Mode autoSaveMode=Auto Export Label Mode
lockBox=Lock selected box/Unlock all box lockBox=Lock selected box/Unlock all box
lockBoxDetail=Lock selected box/Unlock all box lockBoxDetail=Lock selected box/Unlock all box
keyListTitle=Key List
\ No newline at end of file
...@@ -107,3 +107,4 @@ undoLastPoint=撤销上个点 ...@@ -107,3 +107,4 @@ undoLastPoint=撤销上个点
autoSaveMode=自动导出标记结果 autoSaveMode=自动导出标记结果
lockBox=锁定框/解除锁定框 lockBox=锁定框/解除锁定框
lockBoxDetail=若当前没有框处于锁定状态则锁定选中的框,若存在锁定框则解除所有锁定框的锁定状态 lockBoxDetail=若当前没有框处于锁定状态则锁定选中的框,若存在锁定框则解除所有锁定框的锁定状态
keyListTitle=关键词列表
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册