def _get_rgb_by_label(self, label):
if self._config["shape_color"] == "auto":
items = self.uniqLabelList.findItemsByLabel(label)
if items:
item = items[0]
else:
return (0, 255, 0)
label_id = self.uniqLabelList.indexFromItem(item).row() + 1
label_id += self._config["shift_auto_shape_color"]
return LABEL_COLORMAP[label_id % len(LABEL_COLORMAP)]
elif (
self._config["shape_color"] == "manual"
and self._config["label_colors"]
and label in self._config["label_colors"]
):
return self._config["label_colors"][label]
elif self._config["default_shape_color"]:
return self._config["default_shape_color"]
return (0, 255, 0)
debug发现找标签时超出索引,解决方案:找不到item就直接返回(0, 255, 0),将该方法改为以上的代码就行