From 9feec8fe34a1528c34c7def7f13a72db76625472 Mon Sep 17 00:00:00 2001 From: Irony <892768447@qq.com> Date: Sat, 26 Jan 2019 21:00:53 +0800 Subject: [PATCH] text color --- QCalendarWidget/CalendarQssStyle.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/QCalendarWidget/CalendarQssStyle.py b/QCalendarWidget/CalendarQssStyle.py index 6a1ed68..b385325 100644 --- a/QCalendarWidget/CalendarQssStyle.py +++ b/QCalendarWidget/CalendarQssStyle.py @@ -8,6 +8,8 @@ Created on 2018年1月30日 """ import sys +from PyQt5.QtCore import Qt +from PyQt5.QtGui import QTextCharFormat, QBrush, QColor from PyQt5.QtWidgets import QApplication, QCalendarWidget @@ -109,6 +111,17 @@ class CalendarWidget(QCalendarWidget): # 隐藏左边的序号 self.setVerticalHeaderFormat(self.NoVerticalHeader) + # 修改周六周日颜色 + + fmtGreen = QTextCharFormat() + fmtGreen.setForeground(QBrush(Qt.green)) + self.setWeekdayTextFormat(Qt.Saturday, fmtGreen) + + fmtOrange = QTextCharFormat() + fmtOrange.setForeground(QBrush(QColor(252, 140, 28))) + self.setWeekdayTextFormat(Qt.Sunday, fmtOrange) + + if __name__ == "__main__": app = QApplication(sys.argv) app.setStyleSheet(StyleSheet)