Exemple #1
0
                             cy + (r * math.sin(angle)))

        hour, minute = self.displayTime
        hour = hour % 12

        angle = (-math.pi / 2) + (2 * hour * math.pi /
                                  12) + (2 * math.pi / 12 * minute / 60.0)

        painter.setPen(QPen(Qt.black, 8, Qt.SolidLine, Qt.RoundCap))
        painter.drawLine(cx, cy, cx + (0.55 * r * math.cos(angle)),
                         cy + (0.55 * r * math.sin(angle)))

        angle = (-math.pi / 2) + (2 * minute * math.pi / 60)

        painter.drawLine(cx, cy, cx + (0.8 * r * math.cos(angle)),
                         cy + (0.8 * r * math.sin(angle)))

        painter.setPen(QPen(self.foreground))
        painter.setFont(self.font())
        rect = QRect(0, self.height() * 0.75, self.width(), self.maxHeight)
        painter.drawText(rect, Qt.AlignCenter, "%02i:%02i" % self.displayTime)
        painter.end()


if __name__ == "__main__":

    app = buxpaper.Application()
    c = Clock()
    c.showFullScreen()
    sys.exit(app.exec_())
Exemple #2
0
        d = self.power.status()
        self.voltage = int(d["POWER_SUPPLY_VOLTAGE_NOW"])
        self.status = d["POWER_SUPPLY_STATUS"]
        self.update()
    
    def paintEvent(self, event):
    
        painter = QPainter()
        painter.begin(self)
        painter.fillRect(event.rect(), QColor(Qt.white))
        fm = QFontMetricsF(self.font())
        painter.drawText(QRect(0, 0, self.width(), fm.height()), Qt.AlignCenter, "+")
        painter.drawText(QRect(0, self.height() - fm.height(), self.width(), fm.height()),
                         Qt.AlignCenter, "-")
        painter.fillRect(self.width()/4, fm.height() + 50 - self.voltage/2,
                         self.width()/2, self.voltage/2, QColor(Qt.gray))
        painter.drawRect(self.width()/4, fm.height(), self.width()/2, 50)
        painter.end()
    
    def sizeHint(self):
    
        return QSize(self.idealWidth, self.idealHeight)


if __name__ == "__main__":

    app = buxpaper.Application(server = True)
    w = MenuWidget()
    w.showFullScreen()
    sys.exit(app.exec_())