Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with a python script that can run the following, Develop widget clas

ID: 3765100 • Letter: P

Question

Please help with a python script that can run the following,

Develop widget class Calendar that implements a GUI-based calendar application. The Calendar constructor should take as input three arguments: the master widget, a year, and a month (using numbers 1 through 12). For example, Calendar (root, 2012, 2) should create a Calendar widget within the master widget root. The Calendar widget should display the calendar page for the given month and year, with a button for every day:

Hints: you can use the function monthrange from calendar module to get the start weekday and total number of days for a particular month.

This dialog gives you an entry field to enter an appointment. When you click button “OK”, the dialog window will disappear. However, when you click the same day button in the main calendar window again, the dialog window should reappear together with the appointment information.

You may use the askstring function from module tkinter.simpledialog for the dialog window. It takes the window title and label as input and returns whatever the user typed. For example, the last dialog window was created with the function call

askstring('example', 'Enter text')

When the user clicks OK, the string typed in the entry box is returned by this function call. The function can also take an optional argument initial value that takes a string and puts it in the entry field:

askstring('example', ' Enter text', initialvalue='appt with John')

tk Mon Tue Wed Thu Fri Sat Sun 4 6 78910 11 12 13 14 15 16 17 18 19 20 21 22 2324 2526 27 28 29 Then, when you click on a day, a dialog will appear: e00 example Enter text dentist appt OK Cancel )

Explanation / Answer

import sys
from datetime import timedelta
from PyQt4 import QtGui, QtCore

class Calendar(QtGui.QWidget):

    A QCalendarWidget

    def __init__(self):
  
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle('Calendar widget')
    
        self.resize(300,100)
    
        self.vbox = QtGui.QVBoxLayout()
        self.setLayout(self.vbox)
        self.cal = QtGui.QCalendarWidget()
        self.vbox.addWidget(self.cal)
        self.lbl = QtGui.QLabel()
        self.vbox.addWidget(self.lbl)
      
   
        self.connect(self.cal, QtCore.SIGNAL('selectionChanged()'), self.date_changed)

       def date_changed(self):
        Handler called when the date selection has changed
        date = self.cal.selectedDate()
        pydate = date.toPyDate()
        sevendays = timedelta(days=7)
        aweeklater = pydate + sevendays
        self.lbl.setText('The date in a week will be: %s' % aweeklater)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    gui = Calendar()
    gui.show()
    app.exec_()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote