本文整理汇总了Python中qgis.PyQt.QtCore.QDateTime.fromString方法的典型用法代码示例。如果您正苦于以下问题:Python QDateTime.fromString方法的具体用法?Python QDateTime.fromString怎么用?Python QDateTime.fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtCore.QDateTime
的用法示例。
在下文中一共展示了QDateTime.fromString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_app
# 需要导入模块: from qgis.PyQt.QtCore import QDateTime [as 别名]
# 或者: from qgis.PyQt.QtCore.QDateTime import fromString [as 别名]
"""
__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())
示例2: test_existing_complex_keywords
# 需要导入模块: from qgis.PyQt.QtCore import QDateTime [as 别名]
# 或者: from qgis.PyQt.QtCore.QDateTime import fromString [as 别名]
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(
#.........这里部分代码省略.........