|
| 1 | +#!/usr/bin/python3 |
| 2 | +# Calendar v1.0 |
| 3 | +# |
| 4 | + |
| 5 | +from PyQt5.QtWidgets import * |
| 6 | +from PyQt5.QtCore import * |
| 7 | +from PyQt5.QtGui import * |
| 8 | +import sys |
| 9 | + |
| 10 | +class Window(QWidget): |
| 11 | + def __init__(self): |
| 12 | + super(Window,self).__init__() |
| 13 | + global date |
| 14 | + self.setWindowTitle("Calendar") |
| 15 | + self.setGeometry(500,100,500,400) |
| 16 | + self.setFixedSize(500,400) |
| 17 | + cal = QCalendarWidget(self) |
| 18 | + cal.setGridVisible(True) |
| 19 | + cal.move(50,30) |
| 20 | + cal.clicked[QDate].connect(self.show_date) |
| 21 | + self.lbl = QLabel(self) |
| 22 | + self.lbl.setFont(QFont("Arial",18)) |
| 23 | + self.lbl.setGeometry(145,255,400,100) |
| 24 | + # self.lbl.move(170,300) |
| 25 | + date = cal.selectedDate() |
| 26 | + self.lbl.setText(date.toString("yyyy:MM:dd")) |
| 27 | + |
| 28 | + def show_date(self,date): |
| 29 | + self.lbl.setText(date.toString()) |
| 30 | + |
| 31 | + |
| 32 | +def main(): |
| 33 | + # Calendar v1.0 |
| 34 | + app = QApplication(sys.argv) |
| 35 | + app.setApplicationName("Calendar") |
| 36 | + app.setApplicationVersion("v1.0") |
| 37 | + window = Window() |
| 38 | + window.show() |
| 39 | + app.exec_() |
| 40 | + |
| 41 | +if __name__ == "__main__": |
| 42 | + main() |
0 commit comments