本文整理汇总了Python中PyQt5.QtCore.QDate.setDate方法的典型用法代码示例。如果您正苦于以下问题:Python QDate.setDate方法的具体用法?Python QDate.setDate怎么用?Python QDate.setDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QDate
的用法示例。
在下文中一共展示了QDate.setDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setDateStart
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import setDate [as 别名]
def setDateStart(self):
date = self.cal1.selectedDate()
date = date.toPyDate()
self.parent.day_start = datetime.datetime(date.year, date.month, date.day)
self.lbl1.setText(self.parent.day_start.strftime('%d/%m/%Y'))
minDate_dt = self.parent.day_start + datetime.timedelta(days=1)
minDate = QDate()
minDate.setDate(minDate_dt.year, minDate_dt.month, minDate_dt.day)
self.cal2.setMinimumDate(minDate)
示例2: setDateEnd
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import setDate [as 别名]
def setDateEnd(self):
date = self.cal2.selectedDate()
date = date.toPyDate()
self.parent.day_end = datetime.datetime(date.year, date.month, date.day)
self.lbl2.setText(self.parent.day_end.strftime('%d/%m/%Y'))
maxDate_dt = self.parent.day_end - datetime.timedelta(days=1)
maxDate = QDate()
maxDate.setDate(maxDate_dt.year, maxDate_dt.month, maxDate_dt.day)
self.cal1.setMaximumDate(maxDate)
示例3: __init__
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import setDate [as 别名]
def __init__(self, parent):
super(DateInputW, self).__init__()
self.layout = QGridLayout()
self.parent = parent
self.title1 = QLabel(u'Начало:', self)
self.title1.move(5, 5)
self.cal1 = QCalendarWidget()
self.cal1.setGridVisible(True)
self.cal1.setDateEditEnabled(True)
self.cal1.clicked.connect(self.setDateStart)
self.cal1.setFixedSize(200, 160)
ymd1 = [parent.day_start.year, parent.day_start.month, parent.day_start.day]
qdate1 = QDate()
qdate1.setDate(ymd1[0], ymd1[1], ymd1[2])
self.cal1.setSelectedDate(qdate1)
self.lbl1 = QLabel(self)
self.lbl1.setText(parent.day_start.strftime('%d/%m/%Y'))
self.lbl1.move(5, 25)
self.title2 = QLabel(u'Конец:', self)
self.title2.move(325, 5)
self.cal2 = QCalendarWidget()
self.cal2.setGridVisible(True)
self.cal2.setDateEditEnabled(True)
self.cal2.clicked.connect(self.setDateEnd)
self.cal2.setFixedSize(200, 160)
ymd2 = [parent.day_end.year, parent.day_end.month, parent.day_end.day]
qdate2 = QDate()
qdate2.setDate(ymd2[0], ymd2[1], ymd2[2])
self.cal2.setSelectedDate(qdate2)
self.lbl2 = QLabel(self)
self.lbl2.setText(parent.day_end.strftime('%d/%m/%Y'))
self.lbl2.move(325, 25)
self.layout.addWidget(self.cal1, 1, 0)
self.layout.addWidget(self.cal2, 1, 1)
self.setAutoFillBackground(True)
palette = self.palette()
palette.setColor(self.backgroundRole(), QColor('white'))
self.setPalette(palette)
self.setFrameShape(_frameShape)
self.setFrameShadow(_frameShadow)
self.setLineWidth(_lineWidth)
self.setMidLineWidth(_midLineWidth)
#change NavBar background color
child = self.cal1.children()[3]
palette = child.palette()
palette.setColor(child.backgroundRole(), QColor('silver'))
child.setPalette(palette)
child = self.cal2.children()[3]
palette = child.palette()
palette.setColor(child.backgroundRole(), QColor('silver'))
child.setPalette(palette)
# change cell color
brush = self.cal1.paintCell