@@ -370,13 +370,20 @@ def __init__(self, defaultFilename=None, defaultPrefdefClassFile=None, defaultSa
370370 self .singleClassMode .setCheckable (True )
371371 self .singleClassMode .setChecked (settings .get (SETTING_SINGLE_CLASS , False ))
372372 self .lastLabel = None
373+ # Add option to enable/disable labels being painted at the top of bounding boxes
374+ self .paintLabelsOption = QAction ("Paint Labels" , self )
375+ self .paintLabelsOption .setShortcut ("Ctrl+Shift+P" )
376+ self .paintLabelsOption .setCheckable (True )
377+ self .paintLabelsOption .setChecked (False )
378+ self .paintLabelsOption .triggered .connect (self .togglePaintLabelsOption )
373379
374380 addActions (self .menus .file ,
375381 (open , opendir , changeSavedir , openAnnotation , self .menus .recentFiles , save , save_format , saveAs , close , resetAll , quit ))
376382 addActions (self .menus .help , (help , showInfo ))
377383 addActions (self .menus .view , (
378384 self .autoSaving ,
379385 self .singleClassMode ,
386+ self .paintLabelsOption ,
380387 labels , advancedMode , None ,
381388 hideAll , showAll , None ,
382389 zoomIn , zoomOut , zoomOrg , None ,
@@ -709,6 +716,7 @@ def shapeSelectionChanged(self, selected=False):
709716 self .actions .shapeFillColor .setEnabled (selected )
710717
711718 def addLabel (self , shape ):
719+ shape .paintLabel = self .paintLabelsOption .isChecked ()
712720 item = HashableQListWidgetItem (shape .label )
713721 item .setFlags (item .flags () | Qt .ItemIsUserCheckable )
714722 item .setCheckState (Qt .Checked )
@@ -1399,7 +1407,10 @@ def loadYOLOTXTByFilename(self, txtPath):
13991407 self .loadLabels (shapes )
14001408 self .canvas .verified = tYoloParseReader .verified
14011409
1402-
1410+ def togglePaintLabelsOption (self ):
1411+ paintLabelsOptionChecked = self .paintLabelsOption .isChecked ()
1412+ for shape in self .canvas .shapes :
1413+ shape .paintLabel = paintLabelsOptionChecked
14031414
14041415def inverted (color ):
14051416 return QColor (* [255 - v for v in color .getRgb ()])
0 commit comments