-
Notifications
You must be signed in to change notification settings - Fork 0
/
untitled1.py
36 lines (32 loc) · 1.14 KB
/
untitled1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 24 12:56:49 2018
@author: Seamfix
"""
import sys
from PyQt5.QtCore import Qt, QRectF
from PyQt5.QtGui import QPainter,QPalette,QColor
from PyQt5.QtWidgets import QCalendarWidget, QApplication
class dateCalendar(QCalendarWidget):
def __init__(self, parent = None):
super(dateCalendar, self).__init__(parent)
self.color = QColor(self.palette().color(QPalette.Highlight))
self.color.setAlpha(150)
#self.selectionChanged.connect(self.updateCells)
self.dateList = []
def paintCell(self, painter, rect, date):
#calling original paintCell to draw the actual calendar
QCalendarWidget.paintCell(self, painter, rect, date)
#highlight a particular date
if date in self.dateList:
painter.fillRect(rect, self.color)
def selectDates(self, qdatesList):
self.dateList = qdatesList
print(self.dateList)
#this redraws the calendar with your updated date list
self.updateCells()
if __name__ == '__main__':
app = QApplication(sys.argv)
w = dateCalendar()
w.show()
sys.exit(app.exec_())