radar.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:echolocation 作者: hgross 项目源码 文件源码
def _add_circles(self, n, add_text_labels=True):
        """
        Adds n circles to the graphic scene.
        :param n: the number of circles
        """
        pen = QPen(self.circle_line_color)
        pen.setStyle(Qt.DotLine)
        pen.setWidth(self.line_width)
        width, height = self.width(), self.height()
        stepw, steph = width/n, height/n
        mx, my = self._get_middle()

        for i in range(1, n+1):
            w, h = width - i * stepw, height - i * steph
            self.scene.addEllipse((width-w)/2, (height-h)/2, w, h, pen)

            if add_text_labels:
                text = QGraphicsTextItem()
                text.setDefaultTextColor(self.text_label_color)
                text.setPlainText(str(int(w/2)))
                text.setPos(mx+w/2.0, my)

                text2 = QGraphicsTextItem()
                text2.setDefaultTextColor(self.text_label_color)
                text2.setPlainText(str(int(-w / 2)))
                text2.setPos(mx - w / 2.0, my)

                self.scene.addItem(text)
                self.scene.addItem(text2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号