18
18
from napari .layers .utils .layer_utils import _features_to_properties
19
19
from napari .utils .events import Event
20
20
from napari .utils .history import get_save_history , update_save_history
21
- from qtpy .QtCore import Qt , QTimer , Signal , QSize , QPoint , QSettings
22
- from qtpy .QtGui import QPainter , QIcon , QAction , QCursor
21
+ from qtpy .QtCore import Qt , QTimer , Signal , QPoint , QSettings
22
+ from qtpy .QtGui import QPainter , QAction , QCursor
23
23
from qtpy .QtWidgets import (
24
24
QButtonGroup ,
25
25
QCheckBox ,
41
41
QWidget ,
42
42
)
43
43
44
- ICON_FOLDER = os .path .join (os .path .dirname (__file__ ), "assets" )
45
-
46
44
from napari_deeplabcut import keypoints
47
45
from napari_deeplabcut ._reader import _load_config
48
46
from napari_deeplabcut ._writer import _write_config , _write_image , _form_df
@@ -764,8 +762,15 @@ def label_mode(self):
764
762
def label_mode (self , mode : Union [str , keypoints .LabelMode ]):
765
763
self ._label_mode = keypoints .LabelMode (mode )
766
764
self .viewer .status = self .label_mode
765
+ mode_ = str (mode )
766
+ if mode_ == "loop" :
767
+ for menu in self ._menus :
768
+ menu ._locked = True
769
+ else :
770
+ for menu in self ._menus :
771
+ menu ._locked = False
767
772
for btn in self ._radio_group .buttons ():
768
- if btn .text () == str ( mode ) :
773
+ if btn .text () == mode_ :
769
774
btn .setChecked (True )
770
775
break
771
776
@@ -827,11 +832,6 @@ def __init__(
827
832
layout2 = QVBoxLayout ()
828
833
for menu in self .menus .values ():
829
834
layout2 .addWidget (menu )
830
- self .lock_button = QPushButton ("Lock selection" )
831
- self .lock_button .setIcon (QIcon (os .path .join (ICON_FOLDER , "unlock.svg" )))
832
- self .lock_button .setIconSize (QSize (24 , 24 ))
833
- self .lock_button .clicked .connect (self ._lock_current_keypoint )
834
- layout2 .addWidget (self .lock_button )
835
835
group_box .setLayout (layout2 )
836
836
layout1 .addWidget (group_box )
837
837
self .setLayout (layout1 )
@@ -861,15 +861,6 @@ def _update_items(self):
861
861
self .menus ["id" ].update_items (list (self .id2label ))
862
862
self .menus ["label" ].update_items (self .id2label [id_ ])
863
863
864
- def _lock_current_keypoint (self ):
865
- self ._locked = not self ._locked
866
- if self ._locked :
867
- self .lock_button .setText ("Unlock selection" )
868
- self .lock_button .setIcon (QIcon (os .path .join (ICON_FOLDER , "lock.svg" )))
869
- else :
870
- self .lock_button .setText ("Lock selection" )
871
- self .lock_button .setIcon (QIcon (os .path .join (ICON_FOLDER , "unlock.svg" )))
872
-
873
864
def update_menus (self , event ):
874
865
keypoint = self .store .current_keypoint
875
866
for attr , menu in self .menus .items ():
@@ -886,7 +877,7 @@ def refresh_label_menu(self, text: str):
886
877
887
878
def smart_reset (self , event ):
888
879
"""Set current keypoint to the first unlabeled one."""
889
- if self ._locked :
880
+ if self ._locked : # The currently selected point is not updated
890
881
return
891
882
unannotated = ""
892
883
already_annotated = self .store .annotated_keypoints
0 commit comments