diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 7c7802a73ed32680142f8119b10a0393d1fab9cc..c32de8ae28e7114e2803b321bcd079d1de02ce0b 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -987,6 +987,15 @@ class MainWindow(QMainWindow): if len(self.canvas.selectedShapes) == 1 and self.keyList.count() > 0: selected_key_item_row = self.keyList.findItemsByLabel(self.canvas.selectedShapes[0].key_cls, get_row=True) + if isinstance(selected_key_item_row, list) and len(selected_key_item_row) == 0: + key_text = self.canvas.selectedShapes[0].key_cls + item = self.keyList.createItemFromLabel(key_text) + self.keyList.addItem(item) + rgb = self._get_rgb_by_label(key_text, self.kie_mode) + self.keyList.setItemLabel(item, key_text, rgb) + selected_key_item_row = self.keyList.findItemsByLabel(self.canvas.selectedShapes[0].key_cls, + get_row=True) + self.keyList.setCurrentRow(selected_key_item_row) self._noSelectionSlot = False