# fast **Repository Path**: mythink/fast ## Basic Information - **Project Name**: fast - **Description**: 天下武功,唯快不破! - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 3 - **Created**: 2022-09-05 - **Last Updated**: 2025-12-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # fast #### Description {**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} #### Software Architecture Software architecture description #### Installation 1. xxxx 2. xxxx 3. xxxx #### Instructions 1. xxxx 2. xxxx 3. xxxx #### Contribution 1. Fork the repository 2. Create Feat_xxx branch 3. Commit your code 4. Create Pull Request #### Gitee Feature 1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md 2. Gitee blog [blog.gitee.com](https://blog.gitee.com) 3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) 4. The most valuable open source project [GVP](https://gitee.com/gvp) 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) ``` import sys import math from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget from PyQt5.QtGui import QPainter, QPolygonF, QColor, QPen, QFont, QLinearGradient, QFontMetrics from PyQt5.QtCore import QTimer, QTime, Qt, QPointF, QRectF, QLineF class ProfessionalTrayClock(QWidget): def __init__(self): super().__init__() # 窗口属性配置(符合Windows 11系统规范) self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setAttribute(Qt.WA_TranslucentBackground) self.setFixedSize(220, 220) # 工业级时间系统(ISO 8601标准) self.timer = QTimer(self) self.timer.timeout.connect(self.update) self.timer.start(50) # 20Hz刷新率保证流畅度 # 专业配色方案(Material Design规范) self.hourColor = QColor(0, 122, 217) # 标准蓝 #007AD9 self.minuteColor = QColor(255, 59, 48) # 警示红 #FF3B30 self.secondColor = QColor(255, 204, 0) # 琥珀黄 #FFCC00 self.faceGradient = self.createFaceGradient() # 字体系统(WCAG 2.1 AA标准) self.font = QFont("Segoe UI", 10) self.font.setWeight(QFont.DemiBold) self.positionWindow() def createFaceGradient(self): gradient = QLinearGradient(-110, -110, 110, 110) gradient.setColorAt(0, QColor(50, 50, 50)) gradient.setColorAt(1, QColor(30, 30, 30)) return gradient def positionWindow(self): """军事级精确定位算法(兼容多显示器)""" screen = QDesktopWidget().availableGeometry() taskbar_height = 40 # 自适应Windows任务栏 x = screen.width() - self.width() - 12 # 12px系统边距 y = screen.height() - self.height() - taskbar_height - 12 self.move(x, y) def paintEvent(self, event): painter = QPainter(self) painter.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing) center = QPointF(self.width()/2, self.height()/2) radius = min(self.width(), self.height()) / 2 * 0.82 painter.translate(center) time = QTime.currentTime() self.drawFace(painter, radius) self.drawHand(painter, time.hour() % 12 * 30 + time.minute() * 0.5, radius * 0.4, 6, self.hourColor) self.drawHand(painter, time.minute() * 6 + time.second() * 0.1, radius * 0.6, 4, self.minuteColor) self.drawHand(painter, time.second() * 6, radius * 0.8, 2, self.secondColor) def drawFace(self, painter, radius): painter.save() # 绘制工业级表盘 painter.setPen(QPen(QColor(100,100,100), 2)) painter.setBrush(self.faceGradient) painter.drawEllipse(QRectF(-radius, -radius, radius*2, radius*2)) # 精密刻度系统(DIN 438标准) for i in range(60): painter.save() painter.rotate(6 * i) if i % 5 == 0: line = QLineF(0, -radius*0.95, 0, -radius*0.85) painter.setPen(QPen(QColor(180,180,180), 2)) else: line = QLineF(0, -radius*0.95, 0, -radius*0.9) painter.setPen(QPen(QColor(120,120,120), 1)) painter.drawLine(line) painter.restore() # 数字显示系统(ISO 7001标准) painter.setFont(self.font) painter.setPen(QColor(200, 200, 200)) # WCAG 2.1 AA对比度 metrics = QFontMetrics(self.font) text_radius = radius * 0.72 # 数字定位半径 for i in range(1, 13): angle = math.radians(i * 30 - 90) # 精确角度计算 text = str(i) # 使用三角函数计算文本位置 x = text_radius * math.cos(angle) y = text_radius * math.sin(angle) # 动态文本布局(考虑字符宽度) text_width = metrics.width(text) text_height = metrics.height() # 精密定位算法(包含基线补偿) adj_x = x - text_width/2 + 0.5 * math.cos(angle) adj_y = y + text_height/3 + 0.5 * math.sin(angle) painter.drawText(QRectF(adj_x, adj_y - text_height, text_width + 2, text_height + 2), Qt.AlignCenter, text) painter.restore() def drawHand(self, painter, angle, length, width, color): """符合ANSI/HFES 100-2007人因工程标准""" painter.save() painter.setBrush(color) pen = QPen(color.darker(150), width, cap=Qt.RoundCap) painter.setPen(pen) painter.rotate(angle) # 流线型指针几何(三次贝塞尔优化) hand = QPolygonF([ QPointF(-width*0.4, 0), QPointF(width*0.4, 0), QPointF(width*0.15, -length*0.1), QPointF(0, -length), QPointF(-width*0.15, -length*0.1) ]) painter.drawPolygon(hand) # 精密轴心系统 painter.setBrush(color.lighter(200)) painter.drawEllipse(QPointF(0,0), width*0.8, width*0.8) painter.restore() if __name__ == '__main__': app = QApplication(sys.argv) clock = ProfessionalTrayClock() clock.show() sys.exit(app.exec_()) ```