时钟程序:
# -*- coding: utf-8 -*-
"""
【简介】
钟表
"""
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
sed = [QPoint(0, -90), QPoint(2, 0), QPoint(0, 8), QPoint(-2, 0)]#四个坐标点均为逻辑坐标系中的点
minute = [QPoint(0, -70), QPoint(3, 0), QPoint(0, 8), QPoint(-3, 0)]#四个坐标点均为逻辑坐标系中的点
hour = [QPoint(0, -50), QPoint(3, 0), QPoint(0, 8), QPoint(-3, 0)]#四个坐标点均为逻辑坐标系中的点
class Clock(QWidget):
def __init__(self, parent=None):
super(Clock, self).__init__(parent)
self.setWindowTitle("Clock")
# self.resize(300, 300)
self.timer = QTimer(self)
self.timer.start(1000)
self.timer.timeout.connect(self.update)#计时每秒刷新一次,每次刷新触发一次paintEvent
self.clockFont = QFont('宋体', 10)
self.setFont(self.clockFont)
def paintEvent(self, event):
painter = QPainter(self