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


Python QDateEdit.setDisplayFormat方法代碼示例

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


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

示例1: createEditor

# 需要導入模塊: from PyQt4.QtGui import QDateEdit [as 別名]
# 或者: from PyQt4.QtGui.QDateEdit import setDisplayFormat [as 別名]
 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,代碼行數:9,代碼來源:genericdelegates.py

示例2: create_dateedit

# 需要導入模塊: from PyQt4.QtGui import QDateEdit [as 別名]
# 或者: from PyQt4.QtGui.QDateEdit import setDisplayFormat [as 別名]
 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,代碼行數:18,代碼來源:Config.py

示例3: RangeSelection

# 需要導入模塊: from PyQt4.QtGui import QDateEdit [as 別名]
# 或者: from PyQt4.QtGui.QDateEdit import setDisplayFormat [as 別名]
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,代碼行數:47,代碼來源:utils.py

示例4: QtDateSelector

# 需要導入模塊: from PyQt4.QtGui import QDateEdit [as 別名]
# 或者: from PyQt4.QtGui.QDateEdit import setDisplayFormat [as 別名]
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,代碼行數:103,代碼來源:qt_date_selector.py


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