def __init__(self, parent=None): super(dateWindow, self).__init__(parent) self.setWindowTitle(u'日期查询') self.resize(300, 350) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/Imag/Imag/icon.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.setWindowIcon(icon) self.setWindowFlags(Qt.Qt.WindowStaysOnTopHint) self.cal = QtGui.QCalendarWidget(self) self.cal.setGridVisible(True) self.label = QtGui.QLabel(self) self.button = QtGui.QPushButton(self) self.button.setText(u"查 询") date = self.cal.selectedDate() self.label.setText(str(date.toPyDate())) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.label) vbox.addWidget(self.cal) vbox.addWidget(self.button) self.setLayout(vbox) self.connect(self.cal, QtCore.SIGNAL('selectionChanged()'), self.showDate) self.button.clicked.connect(partial(self.button_clicked))
def setupUi(self, FilterLocationsDateDialog): FilterLocationsDateDialog.setObjectName( _fromUtf8("FilterLocationsDateDialog")) FilterLocationsDateDialog.resize(928, 403) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/creepy/calendar")), QtGui.QIcon.Normal, QtGui.QIcon.Off) FilterLocationsDateDialog.setWindowIcon(icon) FilterLocationsDateDialog.setModal(True) self.verticalLayout = QtGui.QVBoxLayout(FilterLocationsDateDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.containerLayout = QtGui.QVBoxLayout() self.containerLayout.setObjectName(_fromUtf8("containerLayout")) self.titleLabel = QtGui.QLabel(FilterLocationsDateDialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.titleLabel.sizePolicy().hasHeightForWidth()) self.titleLabel.setSizePolicy(sizePolicy) self.titleLabel.setObjectName(_fromUtf8("titleLabel")) self.containerLayout.addWidget(self.titleLabel) self.calendarContainerLayout = QtGui.QHBoxLayout() self.calendarContainerLayout.setObjectName( _fromUtf8("calendarContainerLayout")) self.startDateContainer = QtGui.QVBoxLayout() self.startDateContainer.setObjectName(_fromUtf8("startDateContainer")) self.startDateLabel = QtGui.QLabel(FilterLocationsDateDialog) self.startDateLabel.setTextFormat(QtCore.Qt.AutoText) self.startDateLabel.setObjectName(_fromUtf8("startDateLabel")) self.startDateContainer.addWidget(self.startDateLabel) self.stardateCalendarWidget = QtGui.QCalendarWidget( FilterLocationsDateDialog) self.stardateCalendarWidget.setObjectName( _fromUtf8("stardateCalendarWidget")) self.startDateContainer.addWidget(self.stardateCalendarWidget) self.calendarContainerLayout.addLayout(self.startDateContainer) self.endDateContainer = QtGui.QVBoxLayout() self.endDateContainer.setObjectName(_fromUtf8("endDateContainer")) self.endDateLabel = QtGui.QLabel(FilterLocationsDateDialog) self.endDateLabel.setObjectName(_fromUtf8("endDateLabel")) self.endDateContainer.addWidget(self.endDateLabel) self.endDateCalendarWidget = QtGui.QCalendarWidget( FilterLocationsDateDialog) self.endDateCalendarWidget.setObjectName( _fromUtf8("endDateCalendarWidget")) self.endDateContainer.addWidget(self.endDateCalendarWidget) self.calendarContainerLayout.addLayout(self.endDateContainer) self.containerLayout.addLayout(self.calendarContainerLayout) self.timeContainerLayout = QtGui.QHBoxLayout() self.timeContainerLayout.setObjectName( _fromUtf8("timeContainerLayout")) self.startDateTimeEdit = QtGui.QTimeEdit(FilterLocationsDateDialog) self.startDateTimeEdit.setObjectName(_fromUtf8("startDateTimeEdit")) self.timeContainerLayout.addWidget(self.startDateTimeEdit) self.endDateTimeEdit = QtGui.QTimeEdit(FilterLocationsDateDialog) self.endDateTimeEdit.setObjectName(_fromUtf8("endDateTimeEdit")) self.timeContainerLayout.addWidget(self.endDateTimeEdit) self.containerLayout.addLayout(self.timeContainerLayout) self.verticalLayout.addLayout(self.containerLayout) self.buttonBox = QtGui.QDialogButtonBox(FilterLocationsDateDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(FilterLocationsDateDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), FilterLocationsDateDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), FilterLocationsDateDialog.reject) QtCore.QMetaObject.connectSlotsByName(FilterLocationsDateDialog)