@@ -1093,17 +1093,6 @@ def _edit_label(self, value=None):
10931093 assert description is None
10941094 return
10951095
1096- self .canvas .storeShapes ()
1097- for item in items :
1098- self ._update_item (
1099- item = item ,
1100- text = text if edit_text else None ,
1101- flags = flags if edit_flags else None ,
1102- group_id = group_id if edit_group_id else None ,
1103- description = description if edit_description else None ,
1104- )
1105-
1106- def _update_item (self , item , text , flags , group_id , description ):
11071096 if not self .validateLabel (text ):
11081097 self .errorMessage (
11091098 self .tr ("Invalid label" ),
@@ -1113,32 +1102,34 @@ def _update_item(self, item, text, flags, group_id, description):
11131102 )
11141103 return
11151104
1116- shape = item .shape ()
1117-
1118- if text is not None :
1119- shape .label = text
1120- if flags is not None :
1121- shape .flags = flags
1122- if group_id is not None :
1123- shape .group_id = group_id
1124- if description is not None :
1125- shape .description = description
1126-
1127- self ._update_shape_color (shape )
1128- if shape .group_id is None :
1129- item .setText (
1130- '{} <font color="#{:02x}{:02x}{:02x}">●</font>' .format (
1131- html .escape (shape .label ), * shape .fill_color .getRgb ()[:3 ]
1105+ self .canvas .storeShapes ()
1106+ for item in items :
1107+ shape : Shape = item .shape ()
1108+
1109+ if edit_text :
1110+ shape .label = text
1111+ if edit_flags :
1112+ shape .flags = flags
1113+ if edit_group_id :
1114+ shape .group_id = group_id
1115+ if edit_description :
1116+ shape .description = description
1117+
1118+ self ._update_shape_color (shape )
1119+ if shape .group_id is None :
1120+ item .setText (
1121+ '{} <font color="#{:02x}{:02x}{:02x}">●</font>' .format (
1122+ html .escape (shape .label ), * shape .fill_color .getRgb ()[:3 ]
1123+ )
11321124 )
1133- )
1134- else :
1135- item .setText ("{} ({})" .format (shape .label , shape .group_id ))
1136- self .setDirty ()
1137- if self .uniqLabelList .findItemByLabel (shape .label ) is None :
1138- item = self .uniqLabelList .createItemFromLabel (shape .label )
1139- self .uniqLabelList .addItem (item )
1140- rgb = self ._get_rgb_by_label (shape .label )
1141- self .uniqLabelList .setItemLabel (item , shape .label , rgb )
1125+ else :
1126+ item .setText ("{} ({})" .format (shape .label , shape .group_id ))
1127+ self .setDirty ()
1128+ if self .uniqLabelList .findItemByLabel (shape .label ) is None :
1129+ item = self .uniqLabelList .createItemFromLabel (shape .label )
1130+ self .uniqLabelList .addItem (item )
1131+ rgb = self ._get_rgb_by_label (shape .label )
1132+ self .uniqLabelList .setItemLabel (item , shape .label , rgb )
11421133
11431134 def fileSearchChanged (self ):
11441135 self .importDirImages (
0 commit comments