Календарь PyQT
#!/usr/bin/python3
import sys
from PyQt4 import QtGui, QtCore
class Window_Calendar(QtGui.QWidget):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.setGeometry(300,300,700,300)
self.setWindowTitle("Calendar")
self.cal = QtGui.QCalendarWidget(self)
self.cal.setGridVisible(True)
self.cal.move(20,20)
self.connect(self.cal,QtCore.SIGNAL('selectionChanged()'),
self.showDate)
self.cal1 = QtGui.QCalendarWidget(self)
self.cal1.setGridVisible(True)
self.cal1.move(350,20)
self.connect(self.cal1,QtCore.SIGNAL('selectionChanged()'),
self.showDate)
self.label = QtGui.QLabel(self)
date = self.cal.selectedDate()
self.label.setText(str(date.toPyDate()))
self.label.move(130,230)
self.label1 = QtGui.QLabel(self)
date1 = self.cal1.selectedDate()
self.label1.setText(str(date1.toPyDate()))
self.label1.move(430,230)
self.label2 = QtGui.QLabel(self)
self.label2.setText(str(date.toPyDate()-date1.toPyDate()))
self.label2.move(300,250)
def showDate(self):
date = self.cal.selectedDate()
self.label.setText(str(date.toPyDate()))
date1 = self.cal1.selectedDate()
self.label1.setText(str(date1.toPyDate()))
a = date.toPyDate() # type: <class 'datetime.date'>
b = date1.toPyDate()
c = b - a
c = str(c)
if c[0] == '-': c = c[1:]
c = c.split()[0]
self.label2.setText(c)
app = QtGui.QApplication(sys.argv)
window = Window_Calendar()
window.show()
app.exec_()