]> git.droids-corp.org - fpv.git/commitdiff
simplify imports
authorOlivier Matz <zer0@droids-corp.org>
Sun, 7 Jun 2015 16:51:54 +0000 (18:51 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Sun, 7 Jun 2015 16:51:54 +0000 (18:51 +0200)
qtosd/qtosd.py

index b8a51972d4c8d77a5061b92da2bdba341a6c1d35..997934dc24a7b1189b60cb21deef94a2b2298c45 100644 (file)
 import math
 import argparse
 
-from PyQt5 import QtCore, QtGui, QtWidgets
-from PyQt5.QtCore import pyqtSlot
-
+from PyQt5 import QtCore
+from PyQt5.QtCore import (pyqtSlot, QTimer, QRect, QPoint, Qt)
+from PyQt5.QtGui import (QPainter, QColor, QPen, QBrush, QLinearGradient, QFont,
+                         QPainterPath, QPolygonF)
+from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget)
 import serialfpv
 import qtosd_ui
 
@@ -36,14 +38,14 @@ except AttributeError:
         return s
 
 try:
-    _encoding = QtWidgets.QApplication.UnicodeUTF8
+    _encoding = QApplication.UnicodeUTF8
     def _translate(context, text, disambig):
-        return QtWidgets.QApplication.translate(context, text, disambig, _encoding)
+        return QApplication.translate(context, text, disambig, _encoding)
 except AttributeError:
     def _translate(context, text, disambig):
-        return QtWidgets.QApplication.translate(context, text, disambig)
+        return QApplication.translate(context, text, disambig)
 
-class OSDWidget(QtWidgets.QWidget):
+class OSDWidget(QWidget):
     def __init__(self, roundWidget = False, filename = None):
         super(OSDWidget, self).__init__()
         # init parameters
@@ -121,20 +123,20 @@ class OSDWidget(QtWidgets.QWidget):
             self.fpv.open_file(filename)
 
         self.FPS = 50.
-        self.timer = QtCore.QTimer(self)
+        self.timer = QTimer(self)
         self.timer.timeout.connect(self.frameTimerCb)
         self.timer.start(1000. / self.FPS)
 
     @pyqtSlot(name = "paintEvent")
     def paintEvent(self, evt):
         """Paint callback, this is the entry point for all drawings."""
-        painter = QtGui.QPainter()
+        painter = QPainter()
         painter.begin(self)
-        painter.setRenderHint(QtGui.QPainter.Antialiasing)
+        painter.setRenderHint(QPainter.Antialiasing)
         self.dev = evt.rect()
         self.min_dim = min(self.dev.right(), self.dev.bottom())
         self.max_dim = max(self.dev.right(), self.dev.bottom())
-        self.adjdev = QtCore.QRect(0, 0, self.min_dim, self.min_dim)
+        self.adjdev = QRect(0, 0, self.min_dim, self.min_dim)
         self.adjdev.moveCenter(self.dev.center())
         self.draw(painter)
         painter.end()
@@ -186,20 +188,20 @@ class OSDWidget(QtWidgets.QWidget):
 
     def getSkyBrush(self):
         """return the color gradient for the sky (blue)"""
-        sky_gradient = QtGui.QLinearGradient(self.adjdev.topLeft(),
-                                             self.adjdev.bottomRight())
-        color1 = QtCore.Qt.blue
-        color2 = QtCore.Qt.darkBlue
+        sky_gradient = QLinearGradient(self.adjdev.topLeft(),
+                                       self.adjdev.bottomRight())
+        color1 = Qt.blue
+        color2 = Qt.darkBlue
         sky_gradient.setColorAt(0, color1)
         sky_gradient.setColorAt(.8, color2)
         return sky_gradient
 
     def getGroundBrush(self):
         """return the color gradient for the ground (marron)"""
-        ground_gradient = QtGui.QLinearGradient(self.adjdev.topLeft(),
-                                                self.adjdev.bottomRight())
-        color1 = QtGui.QColor(140, 100, 80)
-        color2 = QtGui.QColor(140, 100, 40)
+        ground_gradient = QLinearGradient(self.adjdev.topLeft(),
+                                          self.adjdev.bottomRight())
+        color1 = QColor(140, 100, 80)
+        color2 = QColor(140, 100, 40)
         ground_gradient.setColorAt(0, color1)
         ground_gradient.setColorAt(.8, color2)
         return ground_gradient
@@ -263,11 +265,11 @@ class OSDWidget(QtWidgets.QWidget):
         y_off = (pitch / self.CAM_ANGLE) * dev_r
         painter.translate(center.x(), center.y())
         painter.rotate(roll)
-        ground_rect = QtCore.QRect(0, 0, self.max_dim * 5., self.max_dim * 5.)
+        ground_rect = QRect(0, 0, self.max_dim * 5., self.max_dim * 5.)
         if self.pitch < 90. and self.pitch > -90.:
-            ground_rect.moveCenter(QtCore.QPoint(0, -y_off + ground_rect.width()/2.))
+            ground_rect.moveCenter(QPoint(0, -y_off + ground_rect.width()/2.))
         else:
-            ground_rect.moveCenter(QtCore.QPoint(0, y_off - ground_rect.width()/2.))
+            ground_rect.moveCenter(QPoint(0, y_off - ground_rect.width()/2.))
         painter.setBrush(self.getGroundBrush())
         painter.drawRect(ground_rect)
         painter.restore()
@@ -276,13 +278,13 @@ class OSDWidget(QtWidgets.QWidget):
         """Draw the cross on the middle of the OSD"""
         center = self.adjdev.center()
         r = self.getCenterRadius()
-        pen = QtGui.QPen(QtCore.Qt.red, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.red, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        pt1 = QtCore.QPoint(center.x() - 0.05 * r, center.y())
-        pt2 = QtCore.QPoint(center.x() + 0.05 * r, center.y())
+        pt1 = QPoint(center.x() - 0.05 * r, center.y())
+        pt2 = QPoint(center.x() + 0.05 * r, center.y())
         painter.drawLine(pt1, pt2)
-        pt1 = QtCore.QPoint(center.x(), center.y() + -0.025 * r)
-        pt2 = QtCore.QPoint(center.x(), center.y() + 0.025 * r)
+        pt1 = QPoint(center.x(), center.y() + -0.025 * r)
+        pt2 = QPoint(center.x(), center.y() + 0.025 * r)
         painter.drawLine(pt1, pt2)
 
     def drawPitchGraduation(self, painter):
@@ -300,9 +302,9 @@ class OSDWidget(QtWidgets.QWidget):
         painter.rotate(roll)
 
         # set font and pen
-        pen = QtGui.QPen(QtCore.Qt.white, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.white, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        font = QtGui.QFont("Meiryo UI", 0, QtGui.QFont.Bold)
+        font = QFont("Meiryo UI", 0, QFont.Bold)
         font.setPointSizeF(self.FONT_SIZE * r)
         painter.setFont(font)
 
@@ -316,18 +318,18 @@ class OSDWidget(QtWidgets.QWidget):
         for a in angles:
             # thin line
             if int(a) % int(self.PITCH_REFLINES_BOLD_STEP_ANGLE) != 0:
-                pen = QtGui.QPen(QtCore.Qt.white, r / 100., QtCore.Qt.SolidLine)
+                pen = QPen(Qt.white, r / 100., Qt.SolidLine)
                 painter.setPen(pen)
-                pt1 = QtCore.QPoint(-0.05 * r, dev_r / self.CAM_ANGLE * a)
-                pt2 = QtCore.QPoint(0.05 * r, dev_r / self.CAM_ANGLE * a)
+                pt1 = QPoint(-0.05 * r, dev_r / self.CAM_ANGLE * a)
+                pt2 = QPoint(0.05 * r, dev_r / self.CAM_ANGLE * a)
                 painter.drawLine(pt1, pt2)
                 continue
 
             # bold line
-            pen = QtGui.QPen(QtCore.Qt.white, r / 50., QtCore.Qt.SolidLine)
+            pen = QPen(Qt.white, r / 50., Qt.SolidLine)
             painter.setPen(pen)
-            pt1 = QtCore.QPoint(-0.2 * r, dev_r / self.CAM_ANGLE * a)
-            pt2 = QtCore.QPoint(0.2 * r, dev_r / self.CAM_ANGLE * a)
+            pt1 = QPoint(-0.2 * r, dev_r / self.CAM_ANGLE * a)
+            pt2 = QPoint(0.2 * r, dev_r / self.CAM_ANGLE * a)
             painter.drawLine(pt1, pt2)
 
             # the left text
@@ -338,31 +340,31 @@ class OSDWidget(QtWidgets.QWidget):
                 disp_val = -180. - disp_val
             disp_val = str(int(disp_val))
             metrics = painter.fontMetrics()
-            sz = metrics.size(QtCore.Qt.TextSingleLine, disp_val)
-            lefttxt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
-            lefttxt.moveCenter(pt1 - QtCore.QPoint(0.2 * r, 0))
+            sz = metrics.size(Qt.TextSingleLine, disp_val)
+            lefttxt = QRect(QPoint(0, 0), sz)
+            lefttxt.moveCenter(pt1 - QPoint(0.2 * r, 0))
             # XXX
             #pen.setWidth(1);
-            #brush = QtGui.QBrush(QtCore.Qt.white)
+            #brush = QBrush(Qt.white)
             #painter.setBrush(brush)
-            #pen.setColor(QtCore.Qt.black);
+            #pen.setColor(Qt.black);
             #painter.setPen(pen)
-            #path = QtGui.QPainterPath()
+            #path = QPainterPath()
             #path.addText(lefttxt.center(), font, disp_val)
             #painter.drawPath(path)
-            painter.drawText(lefttxt, QtCore.Qt.TextSingleLine, disp_val)
+            painter.drawText(lefttxt, Qt.TextSingleLine, disp_val)
 
             # flip the right text
             painter.save()
-            painter.translate(pt2 + QtCore.QPoint(0.2 * r, 0))
+            painter.translate(pt2 + QPoint(0.2 * r, 0))
             painter.rotate(180.)
-            painter.translate(-pt2 - QtCore.QPoint(0.2 * r, 0))
-            righttxt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
-            righttxt.moveCenter(pt2 + QtCore.QPoint(0.2 * r, 0))
-            #path = QtGui.QPainterPath()
+            painter.translate(-pt2 - QPoint(0.2 * r, 0))
+            righttxt = QRect(QPoint(0, 0), sz)
+            righttxt.moveCenter(pt2 + QPoint(0.2 * r, 0))
+            #path = QPainterPath()
             #path.addText(righttxt.center(), font, disp_val)
             #painter.drawPath(path)
-            painter.drawText(righttxt, QtCore.Qt.TextSingleLine, disp_val)
+            painter.drawText(righttxt, Qt.TextSingleLine, disp_val)
             painter.restore()
 
         painter.restore()
@@ -373,8 +375,8 @@ class OSDWidget(QtWidgets.QWidget):
         center = self.adjdev.center()
         x = center.x() - math.cos(math.radians(deg)) * r
         y = center.y() - math.sin(math.radians(deg)) * r
-        pt = QtCore.QPoint(x, y)
-        path = QtGui.QPainterPath()
+        pt = QPoint(x, y)
+        path = QPainterPath()
         path.moveTo(pt)
         path.lineTo(center)
         pt2 = path.pointAtPercent(0.075) # graduation len is 7.5% of the radius
@@ -382,7 +384,7 @@ class OSDWidget(QtWidgets.QWidget):
         # then draw the text
         if disp_text == True:
             pt_txt = path.pointAtPercent(0.2)
-            font = QtGui.QFont("Meiryo UI", 0, QtGui.QFont.Bold)
+            font = QFont("Meiryo UI", 0, QFont.Bold)
             font.setPointSizeF(self.FONT_SIZE * r)
             painter.setFont(font)
             disp_val = deg
@@ -390,10 +392,10 @@ class OSDWidget(QtWidgets.QWidget):
                 disp_val = 180. - disp_val
             disp_val = str(int(disp_val))
             metrics = painter.fontMetrics()
-            sz = metrics.size(QtCore.Qt.TextSingleLine, disp_val)
-            txt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
+            sz = metrics.size(Qt.TextSingleLine, disp_val)
+            txt = QRect(QPoint(0, 0), sz)
             txt.moveCenter(pt_txt.toPoint())
-            painter.drawText(txt, QtCore.Qt.TextSingleLine, disp_val)
+            painter.drawText(txt, Qt.TextSingleLine, disp_val)
 
     def drawRollGraduation(self, painter):
         """Draw the roll graduations."""
@@ -404,17 +406,17 @@ class OSDWidget(QtWidgets.QWidget):
         painter.save()
         painter.translate(center.x(), center.y())
         painter.rotate(self.roll)
-        pen = QtGui.QPen(QtCore.Qt.red, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.red, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        pt1 = QtCore.QPoint(-0.925 * r, 0)
-        pt2 = QtCore.QPoint(-0.85 * r, 0)
+        pt1 = QPoint(-0.925 * r, 0)
+        pt2 = QPoint(-0.85 * r, 0)
         painter.drawLine(pt1, pt2)
-        pt1 = QtCore.QPoint(0.925 * r, 0)
-        pt2 = QtCore.QPoint(0.85 * r, 0)
+        pt1 = QPoint(0.925 * r, 0)
+        pt2 = QPoint(0.85 * r, 0)
         painter.drawLine(pt1, pt2)
         painter.restore()
 
-        pen = QtGui.QPen(QtCore.Qt.white, r / 50., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.white, r / 50., Qt.SolidLine)
         painter.setPen(pen)
         deg = 0
         while deg <= 180:
@@ -432,9 +434,9 @@ class OSDWidget(QtWidgets.QWidget):
     def drawYaw(self, painter):
         center = self.adjdev.center()
         r = self.getCenterRadius()
-        pen = QtGui.QPen(QtCore.Qt.red, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.red, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        font = QtGui.QFont("Meiryo UI", 0, QtGui.QFont.Bold)
+        font = QFont("Meiryo UI", 0, QFont.Bold)
         font.setPointSizeF(self.FONT_SIZE * r)
         painter.setFont(font)
         if self.roundWidget == True:
@@ -447,8 +449,8 @@ class OSDWidget(QtWidgets.QWidget):
             y1 = center.y() + r * 1.1
             y2 = center.y() + r * 1.2
             y3 = center.y() + r * 1.25
-        pt1 = QtCore.QPoint(center.x(), y2)
-        pt2 = QtCore.QPoint(center.x(), y3)
+        pt1 = QPoint(center.x(), y2)
+        pt2 = QPoint(center.x(), y3)
         painter.drawLine(pt1, pt2)
 
         # round to nearest angle multiple of step
@@ -462,40 +464,40 @@ class OSDWidget(QtWidgets.QWidget):
             # text (N, S, E, W)
             if int(a) % 90 == 0:
                 disp_text = True
-                pen = QtGui.QPen(QtCore.Qt.white, r / 50., QtCore.Qt.SolidLine)
+                pen = QPen(Qt.white, r / 50., Qt.SolidLine)
                 painter.setPen(pen)
             else:
                 disp_text = False
-                pen = QtGui.QPen(QtCore.Qt.white, r / 100., QtCore.Qt.SolidLine)
+                pen = QPen(Qt.white, r / 100., Qt.SolidLine)
                 painter.setPen(pen)
             # the line
             x = center.x() - ((r / (self.YAW_REFLINES_TOTAL_ANGLE / 2.)) *
                               (self.yaw - a) * self.YAW_REFLINES_SIZE_FACTOR)
-            pt_txt = QtCore.QPoint(x, y_txt)
-            pt1 = QtCore.QPoint(x, y1)
-            pt2 = QtCore.QPoint(x, y2)
+            pt_txt = QPoint(x, y_txt)
+            pt1 = QPoint(x, y1)
+            pt2 = QPoint(x, y2)
             painter.drawLine(pt1, pt2)
             if disp_text == False:
                 continue
             disp_val = ["N", "E", "S", "W"][(int(a)/90)%4]
             metrics = painter.fontMetrics()
-            sz = metrics.size(QtCore.Qt.TextSingleLine, disp_val)
-            txt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
+            sz = metrics.size(Qt.TextSingleLine, disp_val)
+            txt = QRect(QPoint(0, 0), sz)
             txt.moveCenter(pt_txt)
-            painter.drawText(txt, QtCore.Qt.TextSingleLine, disp_val)
+            painter.drawText(txt, Qt.TextSingleLine, disp_val)
 
     def drawSpeed(self, painter):
         center = self.adjdev.center()
         r = self.getCenterRadius()
-        pen = QtGui.QPen(QtCore.Qt.red, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.red, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        font = QtGui.QFont("Meiryo UI", 0, QtGui.QFont.Bold)
+        font = QFont("Meiryo UI", 0, QFont.Bold)
         font.setPointSizeF(self.FONT_SIZE * r)
         painter.setFont(font)
         x1 =  center.x() - 1.5 * r
         x2 =  center.x() - 1.6 * r
-        pt1 = QtCore.QPoint(center.x() - 1.45 * r, center.y())
-        pt2 = QtCore.QPoint(x2, center.y())
+        pt1 = QPoint(center.x() - 1.45 * r, center.y())
+        pt2 = QPoint(x2, center.y())
         painter.drawLine(pt1, pt2)
 
         # round to nearest angle multiple of step
@@ -508,40 +510,40 @@ class OSDWidget(QtWidgets.QWidget):
         for s in speeds:
             if int(s) % int(self.SPEED_REFLINES_BOLD_STEP) == 0:
                 disp_text = True
-                pen = QtGui.QPen(QtCore.Qt.white, r / 50., QtCore.Qt.SolidLine)
+                pen = QPen(Qt.white, r / 50., Qt.SolidLine)
                 painter.setPen(pen)
             else:
                 disp_text = False
-                pen = QtGui.QPen(QtCore.Qt.white, r / 100., QtCore.Qt.SolidLine)
+                pen = QPen(Qt.white, r / 100., Qt.SolidLine)
                 painter.setPen(pen)
             # the line
             y = center.y() + ((r / (self.SPEED_REFLINES_TOTAL/2.)) *
                               (self.speed - s) * self.SPEED_REFLINES_SIZE_FACTOR)
-            pt_txt = QtCore.QPoint(center.x() + r * -1.75, y)
-            pt1 = QtCore.QPoint(x1, y)
-            pt2 = QtCore.QPoint(x2, y)
+            pt_txt = QPoint(center.x() + r * -1.75, y)
+            pt1 = QPoint(x1, y)
+            pt2 = QPoint(x2, y)
             painter.drawLine(pt1, pt2)
             if disp_text == False:
                 continue
             disp_val = str(int(s))
             metrics = painter.fontMetrics()
-            sz = metrics.size(QtCore.Qt.TextSingleLine, disp_val)
-            txt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
+            sz = metrics.size(Qt.TextSingleLine, disp_val)
+            txt = QRect(QPoint(0, 0), sz)
             txt.moveCenter(pt_txt)
-            painter.drawText(txt, QtCore.Qt.TextSingleLine, disp_val)
+            painter.drawText(txt, Qt.TextSingleLine, disp_val)
 
     def drawAlt(self, painter):
         center = self.adjdev.center()
         r = self.getCenterRadius()
-        pen = QtGui.QPen(QtCore.Qt.red, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.red, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        font = QtGui.QFont("Meiryo UI", 0, QtGui.QFont.Bold)
+        font = QFont("Meiryo UI", 0, QFont.Bold)
         font.setPointSizeF(self.FONT_SIZE * r)
         painter.setFont(font)
         x1 =  center.x() + 1.5 * r
         x2 =  center.x() + 1.6 * r
-        pt1 = QtCore.QPoint(center.x() + 1.45 * r, center.y())
-        pt2 = QtCore.QPoint(x2, center.y())
+        pt1 = QPoint(center.x() + 1.45 * r, center.y())
+        pt2 = QPoint(x2, center.y())
         painter.drawLine(pt1, pt2)
 
         # round to nearest angle multiple of step
@@ -554,27 +556,27 @@ class OSDWidget(QtWidgets.QWidget):
         for a in alts:
             if int(a) % int(self.ALT_REFLINES_BOLD_STEP) == 0:
                 disp_text = True
-                pen = QtGui.QPen(QtCore.Qt.white, r / 50., QtCore.Qt.SolidLine)
+                pen = QPen(Qt.white, r / 50., Qt.SolidLine)
                 painter.setPen(pen)
             else:
                 disp_text = False
-                pen = QtGui.QPen(QtCore.Qt.white, r / 100., QtCore.Qt.SolidLine)
+                pen = QPen(Qt.white, r / 100., Qt.SolidLine)
                 painter.setPen(pen)
             # the line
             y = center.y() + ((r / (self.ALT_REFLINES_TOTAL / 2.)) *
                               (self.alt - a) * self.ALT_REFLINES_SIZE_FACTOR)
-            pt_txt = QtCore.QPoint(center.x() + r * 1.75, y)
-            pt1 = QtCore.QPoint(x1, y)
-            pt2 = QtCore.QPoint(x2, y)
+            pt_txt = QPoint(center.x() + r * 1.75, y)
+            pt1 = QPoint(x1, y)
+            pt2 = QPoint(x2, y)
             painter.drawLine(pt1, pt2)
             if disp_text == False:
                 continue
             disp_val = str(int(a))
             metrics = painter.fontMetrics()
-            sz = metrics.size(QtCore.Qt.TextSingleLine, disp_val)
-            txt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
+            sz = metrics.size(Qt.TextSingleLine, disp_val)
+            txt = QRect(QPoint(0, 0), sz)
             txt.moveCenter(pt_txt)
-            painter.drawText(txt, QtCore.Qt.TextSingleLine, disp_val)
+            painter.drawText(txt, Qt.TextSingleLine, disp_val)
 
     def drawReturnToHome(self, painter):
         center = self.adjdev.center()
@@ -583,16 +585,16 @@ class OSDWidget(QtWidgets.QWidget):
         painter.save()
         painter.translate(center.x(), center.y() - 0.9 * dev_r)
         painter.rotate(self.yaw) # XXX
-        pen = QtGui.QPen(QtCore.Qt.white, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.white, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        poly = QtGui.QPolygonF()
-        poly.append(QtCore.QPoint(0., -0.08 * r))
-        poly.append(QtCore.QPoint(0.04 * r, 0.08 * r))
-        poly.append(QtCore.QPoint(-0.04 * r, 0.08 * r))
-        poly.append(QtCore.QPoint(0., -0.08 * r))
-        path = QtGui.QPainterPath()
+        poly = QPolygonF()
+        poly.append(QPoint(0., -0.08 * r))
+        poly.append(QPoint(0.04 * r, 0.08 * r))
+        poly.append(QPoint(-0.04 * r, 0.08 * r))
+        poly.append(QPoint(0., -0.08 * r))
+        path = QPainterPath()
         path.addPolygon(poly)
-        brush = QtGui.QBrush(QtCore.Qt.darkGray)
+        brush = QBrush(Qt.darkGray)
         painter.setBrush(brush)
         painter.drawPath(path)
         painter.restore()
@@ -601,25 +603,25 @@ class OSDWidget(QtWidgets.QWidget):
         center = self.adjdev.center()
         dev_r = self.adjdev.width() / 2.
         r = self.getCenterRadius()
-        pen = QtGui.QPen(QtCore.Qt.white, r / 100., QtCore.Qt.SolidLine)
+        pen = QPen(Qt.white, r / 100., Qt.SolidLine)
         painter.setPen(pen)
-        font = QtGui.QFont("Meiryo UI", 0, QtGui.QFont.Bold)
+        font = QFont("Meiryo UI", 0, QFont.Bold)
         font.setPointSizeF(self.FONT_SIZE * r)
         metrics = painter.fontMetrics()
 
-        sz = metrics.size(QtCore.Qt.AlignLeft, self.left_txt)
-        txt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
-        pt_txt = QtCore.QPoint(center.x() + dev_r * -0.95,
+        sz = metrics.size(Qt.AlignLeft, self.left_txt)
+        txt = QRect(QPoint(0, 0), sz)
+        pt_txt = QPoint(center.x() + dev_r * -0.95,
                                center.y() + dev_r * -0.95)
         txt.moveTopLeft(pt_txt)
-        painter.drawText(txt, QtCore.Qt.AlignLeft, self.left_txt)
+        painter.drawText(txt, Qt.AlignLeft, self.left_txt)
 
-        sz = metrics.size(QtCore.Qt.AlignRight, self.right_txt)
-        txt = QtCore.QRect(QtCore.QPoint(0, 0), sz)
-        pt_txt = QtCore.QPoint(center.x() + dev_r * 0.95,
+        sz = metrics.size(Qt.AlignRight, self.right_txt)
+        txt = QRect(QPoint(0, 0), sz)
+        pt_txt = QPoint(center.x() + dev_r * 0.95,
                                center.y() + dev_r * -0.95)
         txt.moveTopRight(pt_txt)
-        painter.drawText(txt, QtCore.Qt.AlignRight, self.right_txt)
+        painter.drawText(txt, Qt.AlignRight, self.right_txt)
 
     def setPitch(self, pitch):
         """set the pitch in degrees, between -180 and 180"""
@@ -660,7 +662,7 @@ class OSDWidget(QtWidgets.QWidget):
         """set the left text"""
         self.right_txt = txt
 
-class Ui_MainWindow(QtWidgets.QMainWindow):
+class Ui_MainWindow(QMainWindow):
     def __init__(self, parent = None, roundWidget = False, filename = None):
         super(Ui_MainWindow, self).__init__(parent)
         self.ui = qtosd_ui.Ui_MainWindow()
@@ -702,7 +704,7 @@ if __name__ == "__main__":
                         help='specify the log file')
     args = parser.parse_args()
 
-    app = QtWidgets.QApplication(sys.argv)
+    app = QApplication(sys.argv)
     ui = Ui_MainWindow(filename = args.filename, roundWidget = args.round)
     ui.show()
     sys.exit(app.exec_())