Add a button in menu to reset all
This commit is contained in:
parent
32d5954da4
commit
1c5298f13d
BIN
icons/resetall.png
Normal file
BIN
icons/resetall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
25
labelImg.py
25
labelImg.py
@ -44,12 +44,10 @@ __appname__ = 'labelImg'
|
|||||||
|
|
||||||
# Utility functions and classes.
|
# Utility functions and classes.
|
||||||
|
|
||||||
|
|
||||||
def have_qstring():
|
def have_qstring():
|
||||||
'''p3/qt5 get rid of QString wrapper as py3 has native unicode str type'''
|
'''p3/qt5 get rid of QString wrapper as py3 has native unicode str type'''
|
||||||
return not (sys.version_info.major >= 3 or QT_VERSION_STR.startswith('5.'))
|
return not (sys.version_info.major >= 3 or QT_VERSION_STR.startswith('5.'))
|
||||||
|
|
||||||
|
|
||||||
def util_qt_strlistclass():
|
def util_qt_strlistclass():
|
||||||
return QStringList if have_qstring() else list
|
return QStringList if have_qstring() else list
|
||||||
|
|
||||||
@ -225,11 +223,14 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
|
|
||||||
save = action('&Save', self.saveFile,
|
save = action('&Save', self.saveFile,
|
||||||
'Ctrl+S', 'save', u'Save labels to file', enabled=False)
|
'Ctrl+S', 'save', u'Save labels to file', enabled=False)
|
||||||
|
|
||||||
saveAs = action('&Save As', self.saveFileAs,
|
saveAs = action('&Save As', self.saveFileAs,
|
||||||
'Ctrl+Shift+S', 'save-as', u'Save labels to a different file',
|
'Ctrl+Shift+S', 'save-as', u'Save labels to a different file', enabled=False)
|
||||||
enabled=False)
|
|
||||||
close = action('&Close', self.closeFile,
|
close = action('&Close', self.closeFile, 'Ctrl+W', 'close', u'Close current file')
|
||||||
'Ctrl+W', 'close', u'Close current file')
|
|
||||||
|
resetAll = action('&ResetAll', self.resetAll, None, 'resetall', u'Reset all')
|
||||||
|
|
||||||
color1 = action('Box &Line Color', self.chooseColor1,
|
color1 = action('Box &Line Color', self.chooseColor1,
|
||||||
'Ctrl+L', 'color_line', u'Choose Box line color')
|
'Ctrl+L', 'color_line', u'Choose Box line color')
|
||||||
color2 = action('Box &Fill Color', self.chooseColor2,
|
color2 = action('Box &Fill Color', self.chooseColor2,
|
||||||
@ -317,7 +318,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.popLabelListMenu)
|
self.popLabelListMenu)
|
||||||
|
|
||||||
# Store actions for further handling.
|
# Store actions for further handling.
|
||||||
self.actions = struct(save=save, saveAs=saveAs, open=open, close=close,
|
self.actions = struct(save=save, saveAs=saveAs, open=open, close=close, resetAll = resetAll,
|
||||||
lineColor=color1, fillColor=color2,
|
lineColor=color1, fillColor=color2,
|
||||||
create=create, delete=delete, edit=edit, copy=copy,
|
create=create, delete=delete, edit=edit, copy=copy,
|
||||||
createMode=createMode, editMode=editMode, advancedMode=advancedMode,
|
createMode=createMode, editMode=editMode, advancedMode=advancedMode,
|
||||||
@ -326,7 +327,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
fitWindow=fitWindow, fitWidth=fitWidth,
|
fitWindow=fitWindow, fitWidth=fitWidth,
|
||||||
zoomActions=zoomActions,
|
zoomActions=zoomActions,
|
||||||
fileMenuActions=(
|
fileMenuActions=(
|
||||||
open, opendir, save, saveAs, close, quit),
|
open, opendir, save, saveAs, close, resetAll, quit),
|
||||||
beginner=(), advanced=(),
|
beginner=(), advanced=(),
|
||||||
editMenu=(edit, copy, delete,
|
editMenu=(edit, copy, delete,
|
||||||
None, color1, color2),
|
None, color1, color2),
|
||||||
@ -356,7 +357,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.lastLabel = None
|
self.lastLabel = None
|
||||||
|
|
||||||
addActions(self.menus.file,
|
addActions(self.menus.file,
|
||||||
(open, opendir, changeSavedir, openAnnotation, self.menus.recentFiles, save, saveAs, close, None, quit))
|
(open, opendir, changeSavedir, openAnnotation, self.menus.recentFiles, save, saveAs, close, resetAll, quit))
|
||||||
addActions(self.menus.help, (help,))
|
addActions(self.menus.help, (help,))
|
||||||
addActions(self.menus.view, (
|
addActions(self.menus.view, (
|
||||||
self.autoSaving,
|
self.autoSaving,
|
||||||
@ -1208,6 +1209,12 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.canvas.setEnabled(False)
|
self.canvas.setEnabled(False)
|
||||||
self.actions.saveAs.setEnabled(False)
|
self.actions.saveAs.setEnabled(False)
|
||||||
|
|
||||||
|
def resetAll(self):
|
||||||
|
self.settings.reset()
|
||||||
|
self.close()
|
||||||
|
proc = QProcess()
|
||||||
|
proc.startDetached(os.path.abspath(__file__))
|
||||||
|
|
||||||
def mayContinue(self):
|
def mayContinue(self):
|
||||||
return not (self.dirty and not self.discardChangesDialog())
|
return not (self.dirty and not self.discardChangesDialog())
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,10 @@ class Settings(object):
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
with open(self.path, 'wb') as f:
|
if self.path:
|
||||||
pickle.dump(self.data, f, pickle.HIGHEST_PROTOCOL)
|
with open(self.path, 'wb') as f:
|
||||||
return True
|
pickle.dump(self.data, f, pickle.HIGHEST_PROTOCOL)
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
@ -33,3 +34,9 @@ class Settings(object):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
if os.path.exists(self.path):
|
||||||
|
os.remove(self.path)
|
||||||
|
print ('Remove setting pkl file ${0}'.format(self.path))
|
||||||
|
self.data = {}
|
||||||
|
self.path = None
|
||||||
@ -27,6 +27,7 @@
|
|||||||
<file alias="delete">icons/cancel.png</file>
|
<file alias="delete">icons/cancel.png</file>
|
||||||
<file alias="next">icons/next.png</file>
|
<file alias="next">icons/next.png</file>
|
||||||
<file alias="prev">icons/prev.png</file>
|
<file alias="prev">icons/prev.png</file>
|
||||||
|
<file alias="resetall">icons/resetall.png</file>
|
||||||
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user