本文整理汇总了Python中PyQt4.QtGui.QDateEdit.calendarWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QDateEdit.calendarWidget方法的具体用法?Python QDateEdit.calendarWidget怎么用?Python QDateEdit.calendarWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QDateEdit
的用法示例。
在下文中一共展示了QDateEdit.calendarWidget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NewTaskDialog
# 需要导入模块: from PyQt4.QtGui import QDateEdit [as 别名]
# 或者: from PyQt4.QtGui.QDateEdit import calendarWidget [as 别名]
class NewTaskDialog(QDialog):
def __init__(self, parent=None):
super(NewTaskDialog, self).__init__(parent)
# task name
nameLabel = QLabel(self.tr("Name:"))
self.name = QLineEdit()
nameLabel.setBuddy(self.name)
# priority
priorityLabel = QLabel(self.tr("Priority:"))
self.priority = QComboBox()
priorityLabel.setBuddy(self.priority)
dateLabel = QLabel(self.tr("Deadline:"))
self.deadline = QDateEdit()
dateLabel.setBuddy(self.deadline)
self.deadline.setCalendarPopup(True)
self.deadline.calendarWidget().setFirstDayOfWeek(Qt.Monday)
self.deadline.setDate(QDate(date.today()))
createButton = QPushButton(self.tr("Save"))
cancelButton = QPushButton(self.tr("Cancel"))
buttonLayout = QHBoxLayout()
buttonLayout.addStretch()
buttonLayout.addWidget(createButton)
buttonLayout.addWidget(cancelButton)
layout = QGridLayout()
layout.addWidget(nameLabel, 0, 0)
layout.addWidget(self.name, 0, 1)
layout.addWidget(priorityLabel, 1, 0)
layout.addWidget(self.priority, 1, 1)
layout.addWidget(dateLabel, 2, 0)
layout.addWidget(self.deadline, 2, 1)
layout.addLayout(buttonLayout, 3, 0, 3, 2)
self.setLayout(layout)
self.connect(self.deadline, SIGNAL("dateChanged(const QDate&)"), self, SLOT("changed()"))
self.connect(createButton, SIGNAL("clicked()"), self, SLOT("accept()"))
self.connect(cancelButton, SIGNAL("clicked()"), self, SLOT("reject()"))
self.setWindowTitle(self.tr("Task"))
self.resize(350, 120)
self.setMinimumSize(QSize(250, 120))
self.setMaximumSize(QSize(450, 120))
@pyqtSlot()
def changed(self):
print(self.deadline.text())