import sys from PyQt5.QtWidgets import QWidget,QApplication,QCalendarWidget,QPushButton from PyQt5.QtCore import QCalendar,QDate,QDateTime class calendarDemo(QWidget): def __init__(self): super(calendarDemo, self).__init__() # self.calendar = QCalendarWidget(self) self.calendar.setMinimumDate(QDate(1900,1,1)) self.calendar.setMaximumDate(QDate(3600,1,1)) self.calendar.setGridVisible(True) self.calendar.move(50,50) self.calendar.clicked[QDate].connect(self.showDate) self.button = QPushButton(self) date1 = self.calendar.selectedDate() self.button.setText(date1.toString("yyyy-MM-dd dddd")) self.resize(600,400) def showDate(self,date2): self.button.setText(date2.toString("yyyy-MM-dd dddd")) if __name__ == '__main__': app =QApplication(sys.argv) calendar = calendarDemo() calendar.show() sys.exit(app.exec_()) 参考:PyQt5基本控件详解之QCalendar(二十二)_jia666666的博客-CSDN博客
PyQt5之QCalendar(二十三)
最新推荐文章于 2024-10-14 00:05:50 发布