浏览代码

Fix for flake8: labelme/colorDialog.py

Kentaro Wada 7 年之前
父节点
当前提交
54f9544c77
共有 1 个文件被更改,包括 9 次插入14 次删除
  1. 9 14
      labelme/colorDialog.py

+ 9 - 14
labelme/colorDialog.py

@@ -1,4 +1,3 @@
-# flake8: noqa
 #
 # Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
 #
@@ -19,28 +18,24 @@
 #
 
 try:
-    from PyQt5.QtGui import *
-    from PyQt5.QtCore import *
-    from PyQt5.QtWidgets import *
+    from PyQt5 import QtWidgets
 except ImportError:
-    from PyQt4.QtGui import *
-    from PyQt4.QtCore import *
+    from PyQt4 import QtGui as QtWidgets
 
 
-BB = QDialogButtonBox
+class ColorDialog(QtWidgets.QColorDialog):
 
-class ColorDialog(QColorDialog):
     def __init__(self, parent=None):
         super(ColorDialog, self).__init__(parent)
-        self.setOption(QColorDialog.ShowAlphaChannel)
+        self.setOption(QtWidgets.QColorDialog.ShowAlphaChannel)
         # The Mac native dialog does not support our restore button.
-        self.setOption(QColorDialog.DontUseNativeDialog)
-        ## Add a restore defaults button.
+        self.setOption(QtWidgets.QColorDialog.DontUseNativeDialog)
+        # Add a restore defaults button.
         # The default is set at invocation time, so that it
         # works across dialogs for different elements.
         self.default = None
         self.bb = self.layout().itemAt(1).widget()
-        self.bb.addButton(BB.RestoreDefaults)
+        self.bb.addButton(QtWidgets.QDialogButtonBox.RestoreDefaults)
         self.bb.clicked.connect(self.checkRestore)
 
     def getColor(self, value=None, title=None, default=None):
@@ -52,6 +47,6 @@ class ColorDialog(QColorDialog):
         return self.currentColor() if self.exec_() else None
 
     def checkRestore(self, button):
-        if self.bb.buttonRole(button) & BB.ResetRole and self.default:
+        if self.bb.buttonRole(button) & \
+                QtWidgets.QDialogButtonBox.ResetRole and self.default:
             self.setCurrentColor(self.default)
-