当前位置: 首页>>代码示例>>Python>>正文


Python QDateEdit.date方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QDateEdit.date方法的典型用法代码示例。如果您正苦于以下问题:Python QDateEdit.date方法的具体用法?Python QDateEdit.date怎么用?Python QDateEdit.date使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QDateEdit的用法示例。


在下文中一共展示了QDateEdit.date方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DateRangeDialog

# 需要导入模块: from PyQt4.QtGui import QDateEdit [as 别名]
# 或者: from PyQt4.QtGui.QDateEdit import date [as 别名]
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,代码行数:34,代码来源:daterange.py

示例2: RangeSelection

# 需要导入模块: from PyQt4.QtGui import QDateEdit [as 别名]
# 或者: from PyQt4.QtGui.QDateEdit import date [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

示例3: LDSControls

# 需要导入模块: from PyQt4.QtGui import QDateEdit [as 别名]
# 或者: from PyQt4.QtGui.QDateEdit import date [as 别名]

#.........这里部分代码省略.........

        self.confcombo = QComboBox(self)
        self.confcombo.setToolTip('Enter your user config name (file) here')
        self.confcombo.addItems(self.cflist)
        self.confcombo.setEditable(False)
        #self.confcombo.currentIndexChanged.connect(self.doLGEditUpdate)
        
        #combos
        self.lgcombo = QComboBox(self)
        self.lgcombo.setMaximumWidth(self.MAX_WD)
        self.lgcombo.setDuplicatesEnabled(False)
        #self.lgcombo.setInsertPolicy(QComboBox.InsertAlphabetically)#?doesnt seem to work
        self.lgcombo.setToolTip('Select either Layer or Group entry')
        self.lgcombo.setEditable(False)
        self.sepindex = None
        #self.updateLGValues()
        
        self.epsgcombo = QComboBox(self)
        self.epsgcombo.setMaximumWidth(self.MAX_WD)
        self.epsgcombo.setToolTip('Setting an EPSG number here determines the output SR of the layer')  
        self.epsgcombo.addItems([i[1] for i in self.nzlsr])
        self.epsgcombo.insertSeparator(len(self.nzlsr))
        self.epsgcombo.addItems([i[1] for i in self.rowsr])
        self.epsgcombo.setEditable(True)
        self.epsgcombo.setEnabled(False)
        
        self.destlist = self.getConfiguredDestinations()
        self.destcombo = QComboBox(self)
        self.destcombo.setToolTip('Choose the desired output type')   
        self.destcombo.setEditable(False)
        self.destcombo.addItems(self.destlist)

        #date selection
        self.fromdateedit = QDateEdit()
        self.fromdateedit.setCalendarPopup(True)
        self.fromdateedit.setEnabled(False)
        
        self.todateedit = QDateEdit()
        self.todateedit.setCalendarPopup(True)
        self.todateedit.setEnabled(False)
        
        #check boxes
        self.epsgenable = QCheckBox()
        self.epsgenable.setCheckState(False)
        self.epsgenable.clicked.connect(self.doEPSGEnable)       
        
        self.fromdateenable = QCheckBox()
        self.fromdateenable.setCheckState(False)
        self.fromdateenable.clicked.connect(self.doFromDateEnable)
        
        self.todateenable = QCheckBox()
        self.todateenable.setCheckState(False) 
        self.todateenable.clicked.connect(self.doToDateEnable)
        
        self.progressbar = QProgressBar()
        self.progressbar.setRange(0,100)
        self.progressbar.setVisible(True)
        self.progressbar.setMinimumWidth(self.MAX_WD)
        
        
        #buttons        
        self.initbutton = QPushButton("waiting")
        self.initbutton.setToolTip('Initialise the Layer Configuration')
        self.initbutton.clicked.connect(self.doInitClickAction)
        
        self.cleanbutton = QPushButton("Clean")
开发者ID:josephramsay,项目名称:LDS,代码行数:70,代码来源:LDSGUI.py

示例4: QtDateSelector

# 需要导入模块: from PyQt4.QtGui import QDateEdit [as 别名]
# 或者: from PyQt4.QtGui.QDateEdit import date [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.date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。