Ejemplo n.º 1
0
    def paintAxes(self, painter, rect):
        low = int(math.ceil(self.vmin))
        hi = int(math.floor(self.vmax)) + 1
        pen = painter.pen()
        pen.setStyle(Qt.SolidLine)
        pen.setColor(self.line_color)
        painter.setPen(pen)
        fm = QtGui.QFontMetrics(painter.font())
        fw = fm.averageCharWidth()
        fh = fm.height() - 2
        x0 = rect.left()
        x1 = rect.right()
        y0 = rect.bottom()
        y1 = y0 + 4
        lastx = x0

        # horizontal axis
        for tick in range(low, hi):
            s = str(tick)
            w = fw * len(s)
            x = x0 + w / 2 + rect.width() * (
                tick - self.vmin) / float(self.vmax - self.vmin)
            if x - lastx > w + 2 * fw:
                painter.drawLine(x, y0, x, y1)
                painter.drawText(x - w / 2, y1 + fh - 2, s)
                lastx = x

        #vertical axis
        x1 = rect.left()
        lasty = y0
        for tick in range(1, 10):
            t = tick / 10.0
            y = y0 - self.alphaToY(t) * rect.height()
            if lasty - y > fh and y > 2 * fh:
                painter.drawLine(x1 - 5, y, x1, y)
                painter.drawText(x1 - 5 - 3 * fw, y - 2 + fh / 2, str(t))
                lasty = y

        # text boxes
        self.text_boxes["vmin"] = self.paintValueBox(painter, fm, rect.left(),
                                                     y1 + fh, False, self.vmin)
        self.text_boxes["vmax"] = self.paintValueBox(painter, fm, rect.right(),
                                                     y1 + fh, True, self.vmax)
        self.text_boxes["amax"] = self.paintValueBox(painter,
                                                     fm,
                                                     x0 - 4 * fw,
                                                     2 + fh,
                                                     False,
                                                     self.amax,
                                                     format="%.2f")
Ejemplo n.º 2
0
 def update_qt_font(self):
     """
     Updates the font of the PyMod Qt main window.
     """
     self.qfont = QtGui.QFont(self.font, self.font_size)
     self.fm = QtGui.QFontMetrics(self.qfont)