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


Python QtCore.QDateTime类代码示例

本文整理汇总了Python中qgis.PyQt.QtCore.QDateTime的典型用法代码示例。如果您正苦于以下问题:Python QDateTime类的具体用法?Python QDateTime怎么用?Python QDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: outattrPrep

    def outattrPrep(self, dlg, lyr):
        feat = QgsFeature()

        species = ''
        production = ''
        most = QDateTime.currentDateTimeUtc()

        rn = dlg.tableWidget.rowCount()
        for i in range(rn):
            if i==0:
                species = dlg.tableWidget.item(i, 0).text()
                production = dlg.tableWidget.item(i, 1).text()
            else:
                species = species + ' | ' + dlg.tableWidget.item(i, 0).text()
                production = production + ' | ' + dlg.tableWidget.item(i, 1).text()

        flds = lyr.dataProvider().fields()
        feat.setFields(flds, True)
        feat.setAttribute(feat.fieldNameIndex('localid'), dlg.lineEdit_3.text())
        feat.setAttribute(feat.fieldNameIndex('code'), dlg.lineEdit_5.text())
        feat.setAttribute(feat.fieldNameIndex('largescale'), dlg.comboBox_4.currentText())
        feat.setAttribute(feat.fieldNameIndex('disease'), dlg.comboBox_2.currentText())
        feat.setAttribute(feat.fieldNameIndex('animalno'), dlg.lineEdit_6.text())
        feat.setAttribute(feat.fieldNameIndex('species'), species)
        feat.setAttribute(feat.fieldNameIndex('production'), production)
        feat.setAttribute(feat.fieldNameIndex('year'), dlg.lineEdit_4.text())
        feat.setAttribute(feat.fieldNameIndex('status'), dlg.comboBox_3.currentText())
        feat.setAttribute(feat.fieldNameIndex('suspect'), self.dateCheck(dlg.dateEdit.date()))
        feat.setAttribute(feat.fieldNameIndex('confirmation'), self.dateCheck(dlg.dateEdit_2.date()))
        feat.setAttribute(feat.fieldNameIndex('expiration'), self.dateCheck(dlg.dateEdit_3.date()))
        feat.setAttribute(feat.fieldNameIndex('notes'), dlg.textEdit.toPlainText())
        feat.setAttribute(feat.fieldNameIndex('hrid'), self.hashIDer(most))
        feat.setAttribute(feat.fieldNameIndex('timestamp'), most.toString('dd/MM/yyyy hh:mm:ss'))
        return feat
开发者ID:IZSVenezie,项目名称:VetEpiGIS-Tool,代码行数:34,代码来源:qvfuncs.py

示例2: replyFinished

    def replyFinished(self):
        reply = self.sender()
        url = reply.request().url().toString()
        self.log("replyFinished: %s" % url)
        if not url in self.fetchedFiles:
            self.fetchedFiles[url] = None
        self.requestingUrls.remove(url)
        self.replies.remove(reply)
        isFromCache = 0
        httpStatusCode = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
        if reply.error() == QNetworkReply.NoError:
            self.fetchSuccesses += 1
            if reply.attribute(QNetworkRequest.SourceIsFromCacheAttribute):
                self.cacheHits += 1
                isFromCache = 1
            elif not reply.hasRawHeader("Cache-Control"):
                cache = QgsNetworkAccessManager.instance().cache()
                if cache:
                    metadata = cache.metaData(reply.request().url())
                    # self.log("Expiration date: " + metadata.expirationDate().toString().encode("utf-8"))
                    if metadata.expirationDate().isNull():
                        metadata.setExpirationDate(
                            QDateTime.currentDateTime().addSecs(self.default_cache_expiration * 60 * 60))
                        cache.updateMetaData(metadata)
                        self.log(
                            "Default expiration date has been set: %s (%d h)" % (url, self.default_cache_expiration))

            if reply.isReadable():
                data = reply.readAll()
                self.fetchedFiles[url] = data
            else:
                qDebug("http status code: " + str(httpStatusCode))
        else:
            if self.sync and httpStatusCode == 404:
                self.fetchedFiles[url] = self.NOT_FOUND
            self.fetchErrors += 1
            if self.errorStatus == self.NO_ERROR:
                self.errorStatus = self.UNKNOWN_ERROR

        self.replyFinished.emit(url, reply.error(), isFromCache)
        reply.deleteLater()

        if debug_mode:
            qDebug("queue: %d, requesting: %d" % (len(self.queue), len(self.requestingUrls)))

        if len(self.queue) + len(self.requestingUrls) == 0:
            # all replies have been received
            if self.sync:
                self.logT("eventLoop.quit()")
                self.eventLoop.quit()
            else:
                self.timer.stop()
        elif len(self.queue) > 0:
            # start fetching the next file
            self.fetchNext()
        self.log("replyFinished End: %s" % url)
开发者ID:boundlessgeo,项目名称:qgis-baselayers-plugin,代码行数:56,代码来源:downloader.py

示例3: evaluation_test

    def evaluation_test(self, layout, label):
        # $CURRENT_DATE evaluation
        label.setText("__$CURRENT_DATE__")
        assert label.currentText() == ("__" + QDate.currentDate().toString() + "__")

        # $CURRENT_DATE() evaluation
        label.setText("__$CURRENT_DATE(dd)(ok)__")
        expected = "__" + QDateTime.currentDateTime().toString("dd") + "(ok)__"
        assert label.currentText() == expected

        # $CURRENT_DATE() evaluation (inside an expression)
        label.setText("__[%$CURRENT_DATE(dd) + 1%](ok)__")
        dd = QDate.currentDate().day()
        expected = "__%d(ok)__" % (dd + 1)
        assert label.currentText() == expected

        # expression evaluation (without associated feature)
        label.setText("__[%\"NAME_1\"%][%21*2%]__")
        assert label.currentText() == "__[NAME_1]42__"
开发者ID:dmarteau,项目名称:QGIS,代码行数:19,代码来源:test_qgslayoutlabel.py

示例4: start_app

"""
__author__ = 'Denis Rouzaud'
__date__ = '2018-01-04'
__copyright__ = 'Copyright 2017, The QGIS Project'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '885f47d2af26cc804c87a8161ec880893455b0c2'

import qgis  # NOQA

from qgis.gui import QgsDateTimeEdit
from qgis.PyQt.QtCore import Qt, QDateTime
from qgis.testing import start_app, unittest

start_app()

DATE = QDateTime.fromString('2018-01-01 01:02:03', Qt.ISODate)


class TestQgsDateTimeEdit(unittest.TestCase):

    def testSettersGetters(self):
        """ test widget handling of null values """
        w = qgis.gui.QgsDateTimeEdit()
        w.setAllowNull(False)

        w.setDateTime(DATE)
        self.assertEqual(DATE, w.dateTime())
        # date should remain when setting an invalid date
        w.setDateTime(QDateTime())
        self.assertEqual(DATE, w.dateTime())
开发者ID:mbernasocchi,项目名称:QGIS,代码行数:30,代码来源:test_qgsdatetimeedit.py

示例5: test_existing_complex_keywords

    def test_existing_complex_keywords(self):
        """Test for existing complex keywords in wizard in locale mode."""
        from safe.test.utilities import (
            clone_shp_layer, remove_vector_temp_file)
        layer = clone_shp_layer(
            name='tsunami_polygon', include_keywords=True, source_directory='')

        from safe.test.utilities import get_qgis_app
        # Get Qgis app handle
        # noinspection PyPep8Naming
        _, _, IFACE, PARENT = get_qgis_app(qsetting=INASAFE_TEST)

        from safe.gui.tools.wizard.wizard_dialog import WizardDialog

        # noinspection PyTypeChecker
        dialog = WizardDialog(PARENT, IFACE)
        dialog.set_keywords_creation_mode(layer)

        # select hazard
        self.select_from_list_widget('ancaman',
                                     dialog.step_kw_purpose.lstCategories)
        dialog.pbnNext.click()

        # select volcano
        self.select_from_list_widget('gunung berapi', dialog.
                                     step_kw_subcategory.lstSubcategories)
        dialog.pbnNext.click()

        # select volcano categorical unit
        self.select_from_list_widget('Kategori gunung berapi',
                                     dialog.step_kw_unit.lstUnits)
        dialog.pbnNext.click()

        # select GRIDCODE
        self.select_from_list_widget(
            'GRIDCODE', dialog.step_kw_field.lstFields)
        dialog.pbnNext.click()

        unit = dialog.step_kw_unit.selected_unit()
        default_classes = unit['classes']
        unassigned_values = []  # no need to check actually, not save in file
        assigned_values = {
            'low': ['5.0'],
            'medium': ['3.0', '4.0'],
            'high': ['2.0']
        }
        dialog.step_kw_classify.populate_classified_values(
            unassigned_values, assigned_values, default_classes)
        dialog.pbnNext.click()

        source = 'Source'
        source_scale = 'Source Scale'
        source_url = 'Source Url'
        source_date = QDateTime.fromString(
            '06-12-2015 12:30',
            'dd-MM-yyyy HH:mm')

        dialog.step_kw_source.leSource.setText(source)
        dialog.step_kw_source.leSource_scale.setText(source_scale)
        dialog.step_kw_source.leSource_url.setText(source_url)
        dialog.step_kw_source.leSource_date.seDateTime(source_date)
        dialog.pbnNext.click()  # next
        dialog.pbnNext.click()  # finish

        # noinspection PyTypeChecker
        dialog = WizardDialog(PARENT, IFACE)
        dialog.set_keywords_creation_mode(layer)

        # step 1 of 7 - select category
        self.check_current_text(
            'ancaman', dialog.step_kw_purpose.lstCategories)

        # Click Next
        dialog.pbnNext.click()

        # step 2 of 7 - select subcategory
        # noinspection PyTypeChecker
        self.check_current_text('gunung berapi',
                                dialog.step_kw_subcategory.lstSubcategories)

        # Click Next
        dialog.pbnNext.click()

        # step 3 of 7 - select volcano units
        self.check_current_text('Kategori gunung berapi',
                                dialog.step_kw_unit.lstUnits)

        # Click Next
        dialog.pbnNext.click()

        # step 4 of 7 - select field
        self.check_current_text('GRIDCODE', dialog.step_kw_field.lstFields)

        # Click Next
        dialog.pbnNext.click()

        for index in range(dialog.step_classify.lstUniqueValues.count()):
            message = ('%s Should be in unassigned values' %
                       dialog.step_classify.lstUniqueValues.item(index).text())
            self.assertIn(
#.........这里部分代码省略.........
开发者ID:inasafe,项目名称:inasafe,代码行数:101,代码来源:test_wizard_dialog_locale.py


注:本文中的qgis.PyQt.QtCore.QDateTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。