Browse Source

Fix for flake8: labelme/toolBar.py

Kentaro Wada 7 years ago
parent
commit
30f34645e1
1 changed files with 13 additions and 12 deletions
  1. 13 12
      labelme/toolBar.py

+ 13 - 12
labelme/toolBar.py

@@ -1,4 +1,3 @@
-# flake8: noqa
 #
 # Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
 #
@@ -19,15 +18,15 @@
 #
 
 try:
-    from PyQt5.QtGui import *
-    from PyQt5.QtCore import *
-    from PyQt5.QtWidgets import *
+    from PyQt5 import QtCore
+    from PyQt5 import QtWidgets
 except ImportError:
-    from PyQt4.QtGui import *
-    from PyQt4.QtCore import *
+    from PyQt4 import QtCore
+    from PyQt4 import QtGui as QtWidgets
 
 
-class ToolBar(QToolBar):
+class ToolBar(QtWidgets.QToolBar):
+
     def __init__(self, title):
         super(ToolBar, self).__init__(title)
         layout = self.layout()
@@ -35,10 +34,10 @@ class ToolBar(QToolBar):
         layout.setSpacing(0)
         layout.setContentsMargins(*m)
         self.setContentsMargins(*m)
-        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
+        self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint)
 
     def addAction(self, action):
-        if isinstance(action, QWidgetAction):
+        if isinstance(action, QtWidgets.QWidgetAction):
             return super(ToolBar, self).addAction(action)
         btn = ToolButton()
         btn.setDefaultAction(action)
@@ -46,13 +45,15 @@ class ToolBar(QToolBar):
         self.addWidget(btn)
 
 
-class ToolButton(QToolButton):
+class ToolButton(QtWidgets.QToolButton):
+
     """ToolBar companion class which ensures all buttons have the same size."""
+
     minSize = (60, 60)
+
     def minimumSizeHint(self):
         ms = super(ToolButton, self).minimumSizeHint()
         w1, h1 = ms.width(), ms.height()
         w2, h2 = self.minSize
         ToolButton.minSize = max(w1, w2), max(h1, h2)
-        return QSize(*ToolButton.minSize)
-
+        return QtCore.QSize(*ToolButton.minSize)