diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index f7016b6fe85c3ffb60ca17daa59d9c877ad4f0e6..d93c4814cd670b2682017d35a1907dd5b011d457 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -186,9 +186,9 @@ class MainWindow(QMainWindow): self.labelList = EditInList() labelListContainer = QWidget() labelListContainer.setLayout(listLayout) - # self.labelList.itemActivated.connect(self.labelSelectionChanged) self.labelList.itemSelectionChanged.connect(self.labelSelectionChanged) self.labelList.clicked.connect(self.labelList.item_clicked) + # Connect to itemChanged to detect checkbox changes. self.labelList.itemChanged.connect(self.labelItemChanged) self.labelListDock = QDockWidget(getStr('recognitionResult'), self) @@ -1888,7 +1888,10 @@ class MainWindow(QMainWindow): self.canvas.isInTheSameImage = False self.setDirty() elif len(self.result_dic) == len(self.canvas.shapes) and rec_flag == 0: - QMessageBox.information(self, "Information", "The recognition result remains unchanged!") + if self.lang == 'ch': + QMessageBox.information(self, "Information", "识别结果保持一致!") + else: + QMessageBox.information(self, "Information", "The recognition result remains unchanged!") else: print('Can not recgonise in ', self.filePath) else: diff --git a/PPOCRLabel/libs/editinlist.py b/PPOCRLabel/libs/editinlist.py index c1b8249baeab81a22c22f6b183866954b2ee45de..79d2d3aa371ac076de513a4d52ea51b27c6e08f2 100644 --- a/PPOCRLabel/libs/editinlist.py +++ b/PPOCRLabel/libs/editinlist.py @@ -1,31 +1,29 @@ -import sys, time -from PyQt5 import QtWidgets -from PyQt5.QtGui import * -from PyQt5.QtCore import * -from PyQt5.QtWidgets import * +# !/usr/bin/env python +# -*- coding: utf-8 -*- +from PyQt5.QtCore import QModelIndex +from PyQt5.QtWidgets import QListWidget + class EditInList(QListWidget): def __init__(self): - super(EditInList,self).__init__() - # click to edit - self.clicked.connect(self.item_clicked) + super(EditInList, self).__init__() + self.edited_item = None + + def item_clicked(self, modelindex: QModelIndex): + try: + if self.edited_item is not None: + self.closePersistentEditor(self.edited_item) + except: + self.edited_item = self.currentItem() - def item_clicked(self, modelindex: QModelIndex) -> None: - self.edited_item = self.currentItem() - self.closePersistentEditor(self.edited_item) - item = self.item(modelindex.row()) - # time.sleep(0.2) - self.edited_item = item - self.openPersistentEditor(item) - # time.sleep(0.2) - self.editItem(item) + self.edited_item = self.item(modelindex.row()) + self.openPersistentEditor(self.edited_item) + self.editItem(self.edited_item) def mouseDoubleClickEvent(self, event): - # close edit - for i in range(self.count()): - self.closePersistentEditor(self.item(i)) + pass def leaveEvent(self, event): # close edit for i in range(self.count()): - self.closePersistentEditor(self.item(i)) \ No newline at end of file + self.closePersistentEditor(self.item(i))