當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QDateEdit類代碼示例

本文整理匯總了Python中PyQt4.QtGui.QDateEdit的典型用法代碼示例。如果您正苦於以下問題:Python QDateEdit類的具體用法?Python QDateEdit怎麽用?Python QDateEdit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QDateEdit類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, *args, **kwargs):
        MyMplCanvas.__init__(self, *args, **kwargs)


        self.widget = QWidget(self)
        self.horizontalLayout = QHBoxLayout(self.widget)
        self.label_1 = QLabel(self.widget)
        self.horizontalLayout.addWidget(self.label_1)
        self.lineEdit = QLineEdit(self.widget)
        self.horizontalLayout.addWidget(self.lineEdit)
        self.label_2 = QLabel(self.widget)
        self.horizontalLayout.addWidget(self.label_2)
        self.dateEdit = QDateEdit(self.widget)
        self.horizontalLayout.addWidget(self.dateEdit)
        self.label_3 = QLabel(self.widget)
        self.horizontalLayout.addWidget(self.label_3)
        self.dateEdit_2 = QDateEdit(self.widget)
        self.horizontalLayout.addWidget(self.dateEdit_2)
        self.button1 = QPushButton(self.widget)
        self.horizontalLayout.addWidget(self.button1)
        self.button2 = QPushButton(self.widget)
        self.horizontalLayout.addWidget(self.button2)
        self.lineEdit.setText(QtCore.QString('600198'))
        three_month = QtCore.QDate.currentDate().toJulianDay() - 40
        self.dateEdit.setDate(QtCore.QDate.fromJulianDay(three_month))
        self.dateEdit_2.setDate(QtCore.QDate.currentDate())
        self.label_1.setText(_translate("MainWindow", "股票代碼", None))
        self.label_2.setText(_translate("MainWindow", "起始時間", None))
        self.label_3.setText(_translate("MainWindow", "終止時間", None))
        self.button1.setText(_translate("MainWindow", "提交", None))
        self.button2.setText(_translate("MainWindow", "清除", None))

        self.button1.clicked.connect(self.get_value)
        self.button2.clicked.connect(self.clear)
開發者ID:chenqiuyuan,項目名稱:stock_select,代碼行數:34,代碼來源:main.py

示例2: DateRangeDialog

class DateRangeDialog(QDialog):
    def __init__(self):
        super(DateRangeDialog, self).__init__()
        self._fro = QDateEdit(datetime.date.today())
        self._to = QDateEdit(datetime.date.today()
                            + datetime.timedelta(4))

        self._fro.dateChanged.connect(self._check_valid_range)
        self._to.dateChanged.connect(self._check_valid_range)

        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok)
        self.buttons.accepted.connect(self.accept)

        layout = QVBoxLayout()
        layout.addWidget(QLabel('Please select a date range'))
        layout.addWidget(self._fro)
        layout.addWidget(self._to)
        layout.addWidget(self.buttons)
        self.setLayout(layout)


    def _check_valid_range(self):
        self.buttons.button(QDialogButtonBox.Ok)\
            .setEnabled(self._fro.date() <= self._to.date())

    @property
    def fro(self):
        return self._fro.date().toPyDate()

    @property
    def to(self):
        return self._to.date().toPyDate()
開發者ID:madjar,項目名稱:re-eat,代碼行數:32,代碼來源:daterange.py

示例3: createEditor

 def createEditor(self, parent, option, index):
     dateedit = QDateEdit(parent)
     dateedit.setDateRange(self.minimum, self.maximum)
     dateedit.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
     dateedit.setDisplayFormat(self.format)
     dateedit.setCalendarPopup(True)
     return dateedit
開發者ID:DaoQiu,項目名稱:VimProject,代碼行數:7,代碼來源:genericdelegates.py

示例4: CatalogFilterDate

class CatalogFilterDate(CatalogFilter):
    def __init__(self, id):
        super(CatalogFilterDate, self).__init__(id)
        self.label = QLabel(TEXT_LABEL_BETWEEN)

        self.datetime_begin_edit = QDateEdit(QDate.currentDate())
        self.datetime_end_edit = QDateEdit(QDate.currentDate())
        self.datetime_begin_edit.setCalendarPopup(True)
        self.datetime_end_edit.setCalendarPopup(True)
        self.expand_widget(self.datetime_begin_edit)
        self.expand_widget(self.datetime_end_edit)

        value_item = QGridLayout()
        value_item.addWidget(self.datetime_begin_edit, 0, 0)
        value_item.addWidget(QLabel(TEXT_LABEL_AND), 0, 1)
        value_item.addWidget(self.datetime_end_edit, 0, 2)
        self.value_item = value_item

    def get_query_filters(self):
        # date request filter values are returned by get_datetime_begin/end
        return []

    def validate(self, errors):
        datetime_begin = self.datetime_begin_edit.dateTime()
        datetime_end = self.datetime_end_edit.dateTime()
        if datetime_begin.daysTo(datetime_end) < 0:
            errors.append("First value must be less than or equal to second for %s filter." % self.column_name)

    def get_datetime_begin(self):
        return self.datetime_begin_edit.dateTime().toString(DATETIME_FORMAT)

    def get_datetime_end(self):
        return self.datetime_end_edit.dateTime().toString(DATETIME_FORMAT)
開發者ID:DigitalGlobe,項目名稱:DGConnect,代碼行數:33,代碼來源:CatalogFilters.py

示例5: __init__

    def __init__(self, *args, **kwargs):
        MyMplCanvas.__init__(self, *args, **kwargs)
        # 初始化變量,以控製圖表的顯示
        self.control = {"basic":True,
                        "extreme":True,
                        "slope":True,
                        "star":True}

        self.widget = QWidget(self)
        self.horizontalLayout = QHBoxLayout(self.widget)
        self.label_1 = QLabel(self.widget)
        self.horizontalLayout.addWidget(self.label_1)
        self.lineEdit = QLineEdit(self.widget)
        self.horizontalLayout.addWidget(self.lineEdit)
        self.label_2 = QLabel(self.widget)
        self.horizontalLayout.addWidget(self.label_2)
        self.dateEdit = QDateEdit(self.widget)
        self.horizontalLayout.addWidget(self.dateEdit)
        self.label_3 = QLabel(self.widget)
        self.horizontalLayout.addWidget(self.label_3)
        self.dateEdit_2 = QDateEdit(self.widget)
        self.horizontalLayout.addWidget(self.dateEdit_2)
        self.button1 = QPushButton(self.widget)
        self.horizontalLayout.addWidget(self.button1)
        self.button2 = QPushButton(self.widget)
        self.horizontalLayout.addWidget(self.button2)
        self.button3 = QPushButton(self.widget)
        self.horizontalLayout.addWidget(self.button3)
        self.button4 = QPushButton(self.widget)
        self.horizontalLayout.addWidget(self.button4)
        self.button5 = QPushButton(self.widget)
        self.horizontalLayout.addWidget(self.button5)
        self.lineEdit.setText(QtCore.QString('002594'))
        three_month = QtCore.QDate.currentDate().toJulianDay() - 150
        self.dateEdit.setDate(QtCore.QDate.fromJulianDay(three_month))
        self.dateEdit_2.setDate(QtCore.QDate.currentDate())
        self.label_1.setText(_translate("MainWindow", "股票代碼", None))
        self.label_2.setText(_translate("MainWindow", "起始時間", None))
        self.label_3.setText(_translate("MainWindow", "終止時間", None))
        self.button1.setText(_translate("MainWindow", "所有", None))
        self.button2.setText(_translate("MainWindow", "極端", None))
        self.button3.setText(_translate("MainWindow", "斜率", None))
        self.button4.setText(_translate("MainWindow", "趨勢", None))
        self.button5.setText(_translate("MainWindow", "清除", None))

        self.button1.clicked.connect(self.draw_all)
        self.button2.clicked.connect(self.draw_extreme)
        self.button3.clicked.connect(self.draw_slope)
        self.button4.clicked.connect(self.draw_trend)
        self.button5.clicked.connect(self.clear)
開發者ID:chenqiuyuan,項目名稱:stock_select,代碼行數:50,代碼來源:main.py

示例6: __init__

    def __init__(self, id):
        super(CatalogFilterDate, self).__init__(id)
        self.label = QLabel(TEXT_LABEL_BETWEEN)

        self.datetime_begin_edit = QDateEdit(QDate.currentDate())
        self.datetime_end_edit = QDateEdit(QDate.currentDate())
        self.datetime_begin_edit.setCalendarPopup(True)
        self.datetime_end_edit.setCalendarPopup(True)
        self.expand_widget(self.datetime_begin_edit)
        self.expand_widget(self.datetime_end_edit)

        value_item = QGridLayout()
        value_item.addWidget(self.datetime_begin_edit, 0, 0)
        value_item.addWidget(QLabel(TEXT_LABEL_AND), 0, 1)
        value_item.addWidget(self.datetime_end_edit, 0, 2)
        self.value_item = value_item
開發者ID:DigitalGlobe,項目名稱:DGConnect,代碼行數:16,代碼來源:CatalogFilters.py

示例7: RangeSelection

class RangeSelection(QWidget):
    """
    Allow to select a date, a build id, a release number or an arbitrary
    changeset.
    """
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        layout = QHBoxLayout(self)
        self._create_widgets()
        layout.addWidget(self.stacked)
        layout.addWidget(self.select_combo)
        self.setLayout(layout)

    def _create_widgets(self):
        self.stacked = QStackedWidget()
        self.datew = QDateEdit()
        self.datew.setDisplayFormat("yyyy-MM-dd")
        self.stacked.addWidget(self.datew)
        self.buildidw = QLineEdit()
        self.stacked.addWidget(self.buildidw)
        self.releasew = QComboBox()
        self.releasew.addItems([str(k) for k in sorted(releases())])
        self.stacked.addWidget(self.releasew)
        self.revw = QLineEdit()
        self.stacked.addWidget(self.revw)

        self.select_combo = QComboBox()
        self.select_combo.addItems(['date', 'buildid', 'release', 'changeset'])
        self.select_combo.activated.connect(self.stacked.setCurrentIndex)

    def get_value(self):
        currentw = self.stacked.currentWidget()
        if currentw == self.datew:
            return self.datew.date().toPyDate()
        elif currentw == self.buildidw:
            buildid = unicode(self.buildidw.text())
            try:
                return parse_date(buildid)
            except DateFormatError:
                raise DateFormatError(buildid, "Not a valid build id: `%s`")
        elif currentw == self.releasew:
            return parse_date(
                date_of_release(str(self.releasew.currentText())))
        elif currentw == self.revw:
            return unicode(self.revw.text())
開發者ID:GopianiS,項目名稱:mozregression,代碼行數:45,代碼來源:utils.py

示例8: __init__

    def __init__(self):
        super(DateRangeDialog, self).__init__()
        self._fro = QDateEdit(datetime.date.today())
        self._to = QDateEdit(datetime.date.today()
                            + datetime.timedelta(4))

        self._fro.dateChanged.connect(self._check_valid_range)
        self._to.dateChanged.connect(self._check_valid_range)

        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok)
        self.buttons.accepted.connect(self.accept)

        layout = QVBoxLayout()
        layout.addWidget(QLabel('Please select a date range'))
        layout.addWidget(self._fro)
        layout.addWidget(self._to)
        layout.addWidget(self.buttons)
        self.setLayout(layout)
開發者ID:madjar,項目名稱:re-eat,代碼行數:18,代碼來源:daterange.py

示例9: create_dateedit

 def create_dateedit(self, text, option, tip=None):
     label = QLabel(text)
     dateedit = QDateEdit()
     dateedit.setDisplayFormat('dd MMM yyyy')
     dateedit.setMaximumDate(QDate(2010,12,31))
     dateedit.setMinimumDate(QDate(2002,01,01))
     if tip is not None: dateedit.setToolTip(tip)
     self.dateedits[dateedit] = option
     layout = QHBoxLayout()
     for subwidget in (label, dateedit):
         layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
開發者ID:sarahdi,項目名稱:openfisca,代碼行數:16,代碼來源:Config.py

示例10: DlgCredito

class DlgCredito( QDialog ):
    def __init__( self, parent = None ):
        super( DlgCredito, self ).__init__( parent )

        self.dtFechaTope = QDateEdit( QDate.currentDate().addDays( 1 ) )
        self.dtFechaTope.setMinimumDate( QDate.currentDate().addDays( 1 ) )
        """
        @ivar: Este widget tiene la fecha tope en la que puede 
            pagarse el credito
        @type: QDateEdit
        """
        self.sbTaxRate = QDoubleSpinBox()
        """
        @ivar: Este widget contiene la tasa de multa que se
            le aplicara a este credito
        @typ: QDoubleSpinBox
        """

        self.setupUi()

    def setupUi( self ):
        vertical_layout = QVBoxLayout( self )

        form_layout = QFormLayout()

        self.dtFechaTope.setCalendarPopup( True )
        self.sbTaxRate.setSuffix( '%' )

        form_layout.addRow( u"<b>Fecha Tope</b>", self.dtFechaTope )
        form_layout.addRow( u"<b>Tasa de multa</b>", self.sbTaxRate )

        buttonbox = QDialogButtonBox( QDialogButtonBox.Ok |
                                      QDialogButtonBox.Cancel )

        vertical_layout.addLayout( form_layout )
        vertical_layout.addWidget( buttonbox )

        buttonbox.accepted.connect( self.accept )
        buttonbox.rejected.connect( self.reject )
開發者ID:armonge,項目名稱:EsquipulasPy,代碼行數:39,代碼來源:factura.py

示例11: NewTaskDialog

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())
開發者ID:i-wind,項目名稱:pyqt_todo,代碼行數:53,代碼來源:dlg_newtask.py

示例12: _create_widgets

    def _create_widgets(self):
        self.stacked = QStackedWidget()
        self.datew = QDateEdit()
        self.datew.setDisplayFormat("yyyy-MM-dd")
        self.stacked.addWidget(self.datew)
        self.buildidw = QLineEdit()
        self.stacked.addWidget(self.buildidw)
        self.releasew = QComboBox()
        self.releasew.addItems([str(k) for k in sorted(releases())])
        self.stacked.addWidget(self.releasew)

        self.select_combo = QComboBox()
        self.select_combo.addItems(['date', 'buildid', 'release'])
        self.select_combo.activated.connect(self.stacked.setCurrentIndex)
開發者ID:pombredanne,項目名稱:mozregression,代碼行數:14,代碼來源:utils.py

示例13: __init__

    def __init__( self, parent = None ):
        super( DlgCredito, self ).__init__( parent )

        self.dtFechaTope = QDateEdit( QDate.currentDate().addDays( 1 ) )
        self.dtFechaTope.setMinimumDate( QDate.currentDate().addDays( 1 ) )
        """
        @ivar: Este widget tiene la fecha tope en la que puede 
            pagarse el credito
        @type: QDateEdit
        """
        self.sbTaxRate = QDoubleSpinBox()
        """
        @ivar: Este widget contiene la tasa de multa que se
            le aplicara a este credito
        @typ: QDoubleSpinBox
        """

        self.setupUi()
開發者ID:armonge,項目名稱:EsquipulasPy,代碼行數:18,代碼來源:factura.py

示例14: QtDateSelector

class QtDateSelector(QtBoundedDate, ProxyDateSelector):
    """ A Qt implementation of an Enaml ProxyDateSelector.

    """

    #: A reference to the widget created by the proxy.
    widget = Typed(QDateEdit)

    # --------------------------------------------------------------------------
    # Initialization API
    # --------------------------------------------------------------------------
    def create_widget(self):
        """ Create the QDateEdit widget.

        """
        self.widget = QDateEdit(self.parent_widget())

    def init_widget(self):
        """ Initialize the widget.

        """
        super(QtDateSelector, self).init_widget()
        d = self.declaration
        self.set_date_format(d.date_format)
        self.set_calendar_popup(d.calendar_popup)
        self.widget.dateChanged.connect(self.on_date_changed)

    # --------------------------------------------------------------------------
    # Abstract API Implementation
    # --------------------------------------------------------------------------
    def get_date(self):
        """ Return the current date in the control.

        Returns
        -------
        result : date
            The current control date as a date object.

        """
        return self.widget.date().toPyDate()

    def set_minimum(self, date):
        """ Set the widget's minimum date.

        Parameters
        ----------
        date : date
            The date object to use for setting the minimum date.

        """
        self.widget.setMinimumDate(date)

    def set_maximum(self, date):
        """ Set the widget's maximum date.

        Parameters
        ----------
        date : date
            The date object to use for setting the maximum date.

        """
        self.widget.setMaximumDate(date)

    def set_date(self, date):
        """ Set the widget's current date.

        Parameters
        ----------
        date : date
            The date object to use for setting the date.

        """
        self._guard |= CHANGED_GUARD
        try:
            self.widget.setDate(date)
        finally:
            self._guard &= ~CHANGED_GUARD

    def set_date_format(self, format):
        """ Set the widget's date format.

        Parameters
        ----------
        format : str
            A Python time formatting string.

        """
        # XXX make sure Python's and Qt's format strings are the
        # same, or convert between the two.
        self.widget.setDisplayFormat(format)

    def set_calendar_popup(self, popup):
        """ Set whether a calendar popup is available on the widget.

        Parameters
        ----------
        popup : bool
            Whether the calendar popup is enabled.

        """
#.........這裏部分代碼省略.........
開發者ID:ContinuumIO,項目名稱:enaml,代碼行數:101,代碼來源:qt_date_selector.py

示例15: __init__

    def __init__(self, parent=None):
        super(TalkDetailsWidget, self).__init__(parent)

        self.layout = QGridLayout()
        self.setLayout(self.layout)

        self.buttonLayout = QHBoxLayout()

        addIcon = QIcon.fromTheme("list-add")
        self.addButton = QPushButton("Add New Talk")
        self.addButton.setIcon(addIcon)
        self.buttonLayout.addWidget(self.addButton)
        saveIcon = QIcon.fromTheme("document-save")
        self.saveButton = QPushButton("Save New Talk")
        self.saveButton.setIcon(saveIcon)
        self.buttonLayout.addWidget(self.saveButton)

        self.layout.addLayout(self.buttonLayout, 0, 1, 1, 1)

        self.titleLabel = QLabel("Title")
        self.titleLineEdit = QLineEdit()
        self.layout.addWidget(self.titleLabel, 1, 0, 1, 1)
        self.layout.addWidget(self.titleLineEdit, 1, 1, 1, 3)

        self.presenterLabel = QLabel("Presenter")
        self.presenterLineEdit = QLineEdit()

        self.categoryLabel = QLabel("Category")
        self.categoryLineEdit = QLineEdit()

        self.layout.addWidget(self.presenterLabel, 2, 0, 1, 1)
        self.layout.addWidget(self.presenterLineEdit, 2, 1, 1, 1)
        self.layout.addWidget(self.categoryLabel, 2, 2, 1, 1)
        self.layout.addWidget(self.categoryLineEdit, 2, 3, 1, 1)

        self.eventLabel = QLabel("Event")
        self.eventLineEdit = QLineEdit()
        self.roomLabel = QLabel("Room")
        self.roomLineEdit = QLineEdit()

        self.layout.addWidget(self.eventLabel, 3, 0, 1, 1)
        self.layout.addWidget(self.eventLineEdit, 3, 1, 1, 1)
        self.layout.addWidget(self.roomLabel, 3, 2, 1, 1)
        self.layout.addWidget(self.roomLineEdit, 3, 3, 1, 1)

        self.dateLayout = QHBoxLayout()
        self.timeLayout = QHBoxLayout()
        self.dateLabel = QLabel("Date")
        self.dateEdit = QDateEdit()
        currentDate = QDate()
        self.dateEdit.setDate(currentDate.currentDate())
        self.dateEdit.setCalendarPopup(True)
        self.timeLabel = QLabel("Time")
        self.timeEdit = QTimeEdit()

        self.dateLayout.addWidget(self.dateEdit)
        self.timeLayout.addWidget(self.timeEdit)
        self.layout.addWidget(self.dateLabel, 4, 0, 1, 1)
        self.layout.addLayout(self.dateLayout, 4, 1, 1, 1)
        self.layout.addWidget(self.timeLabel, 4, 2, 1, 1)
        self.layout.addLayout(self.timeLayout, 4, 3, 1, 1)

        self.descriptionLabel = QLabel("Description")
        self.descriptionLabel.setAlignment(Qt.AlignTop)
        self.descriptionTextEdit = QPlainTextEdit()
        self.layout.addWidget(self.descriptionLabel, 5, 0, 1, 1)
        self.layout.addWidget(self.descriptionTextEdit, 5, 1, 1, 3)
開發者ID:jshyeung,項目名稱:freeseer,代碼行數:67,代碼來源:TalkDetailsWidget.py


注:本文中的PyQt4.QtGui.QDateEdit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。