Skip to content

Commit

Permalink
Fix #266, #285. 'keep_prev' mode is visible in Edit menu and switchab…
Browse files Browse the repository at this point in the history
…le (#286)

* Fix #266, #285. 'keep_prev' mode state is visible in Edit menu and switchable there

* Fix #266, #285. 'keep_prev' mode state is visible in Edit menu and switchable there
+ flake8 fixes
  • Loading branch information
IlyaOvodov authored and wkentaro committed Jan 2, 2019
1 parent 706dd36 commit 27ce594
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ def __init__(
shortcuts['edit_fill_color'], 'color',
'Choose polygon fill color')

toggle_keep_prev_mode = action(
'Keep Previous Annotation',
self.toggleKeepPrevMode,
shortcuts['toggle_keep_prev_mode'], None,
'Toggle "keep pevious annotation" mode',
checkable=True)
toggle_keep_prev_mode.setChecked(self._config['keep_prev'])

createMode = action(
'Create Polygons',
lambda: self.toggleDrawMode(False, createMode='polygon'),
Expand Down Expand Up @@ -411,6 +419,7 @@ def __init__(
changeOutputDir=changeOutputDir,
save=save, saveAs=saveAs, open=open_, close=close,
lineColor=color1, fillColor=color2,
toggleKeepPrevMode=toggle_keep_prev_mode,
delete=delete, edit=edit, copy=copy,
undoLastPoint=undoLastPoint, undo=undo,
addPoint=addPoint,
Expand All @@ -428,7 +437,7 @@ def __init__(
fileMenuActions=(open_, opendir, save, saveAs, close, quit),
tool=(),
editMenu=(edit, copy, delete, None, undo, undoLastPoint,
None, color1, color2),
None, color1, color2, None, toggle_keep_prev_mode),
# menu shown at right click
menu=(
createMode,
Expand Down Expand Up @@ -1435,6 +1444,9 @@ def chooseColor2(self):
self.canvas.update()
self.setDirty()

def toggleKeepPrevMode(self):
self._config['keep_prev'] = not self._config['keep_prev']

def deleteSelectedShape(self):
yes, no = QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No
msg = 'You are about to permanently delete this polygon, ' \
Expand Down
1 change: 1 addition & 0 deletions labelme/config/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ shortcuts:
edit_label: Ctrl+E
edit_line_color: Ctrl+L
edit_fill_color: Ctrl+Shift+L
toggle_keep_prev_mode: Ctrl+P

0 comments on commit 27ce594

Please sign in to comment.