瀏覽代碼

Add --reset-config arg

Kentaro Wada 6 年之前
父節點
當前提交
ece71201c4
共有 1 個文件被更改,包括 13 次插入2 次删除
  1. 13 2
      labelme/main.py

+ 13 - 2
labelme/main.py

@@ -15,8 +15,12 @@ from labelme.utils import newIcon
 
 def main():
     parser = argparse.ArgumentParser()
-    parser.add_argument('--version', '-V', action='store_true',
-                        help='show version')
+    parser.add_argument(
+        '--version', '-V', action='store_true', help='show version'
+    )
+    parser.add_argument(
+        '--reset-config', action='store_true', help='reset qt config'
+    )
     parser.add_argument('filename', nargs='?', help='image or label filename')
     parser.add_argument('--output', '-O', '-o', help='output label name')
     default_config_file = os.path.join(os.path.expanduser('~'), '.labelmerc')
@@ -99,6 +103,7 @@ def main():
 
     config_from_args = args.__dict__
     config_from_args.pop('version')
+    reset_config = config_from_args.pop('reset_config')
     filename = config_from_args.pop('filename')
     output = config_from_args.pop('output')
     config_file = config_from_args.pop('config_file')
@@ -114,6 +119,12 @@ def main():
     app.setApplicationName(__appname__)
     app.setWindowIcon(newIcon('icon'))
     win = MainWindow(config=config, filename=filename, output=output)
+
+    if reset_config:
+        print('Resetting Qt config: %s' % win.settings.fileName())
+        win.settings.clear()
+        sys.exit(0)
+
     win.show()
     win.raise_()
     sys.exit(app.exec_())