user1114835
user1114835

Reputation:

how to attach appointments to a calender widget pyqt and python

import sys
from PyQt4 import QtGui, QtCore

class Example(QtGui.QWidget):

    def __init__(self):
         super(Example, self).__init__()

         self.initUI()

    def initUI(self):      

        cal = QtGui.QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(20, 20)
        cal.clicked[QtCore.QDate].connect(self.showDate)

        self.lbl = QtGui.QLabel(self)
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        self.lbl.move(130, 260)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()

   def showDate(self, date):     
        self.lbl.setText(date.toString())

def main():

    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()

this code generates a calender widget with the date showing, I need to be able to attach so called appointments to there relevant date via user input and then show the user that there is an appointment attached to that date i.e the date turns red

it would also be handy for me to have all the appointments in a list (or text file) so that a user can view them all at once should they choose to

thanks in advance

Upvotes: 0

Views: 1427

Answers (1)

mata
mata

Reputation: 69082

the QCalendarWidget is intended as a date selector, so it's not really made for what you try to do. If you only want to render certain cells differently, then you cann create your on class derived from QCalendarWidget and override it's paintCell() method.

Upvotes: 1

Related Questions