本文整理汇总了Python中safe_qgis.tools.keywords_dialog.KeywordsDialog类的典型用法代码示例。如果您正苦于以下问题:Python KeywordsDialog类的具体用法?Python KeywordsDialog怎么用?Python KeywordsDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeywordsDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_value_for_key
def test_get_value_for_key(self):
"""Test get value for key works."""
make_padang_layer()
dialog = KeywordsDialog(PARENT, IFACE)
expected_value = 'hazard'
value = dialog.get_value_for_key('category')
self.assertEqual(value, expected_value)
示例2: show_keywords_editor
def show_keywords_editor(self):
"""Show the keywords editor."""
# import here only so that it is AFTER i18n set up
from safe_qgis.tools.keywords_dialog import KeywordsDialog
# Next block is a fix for #776
if self.iface.activeLayer() is None:
return
try:
keyword_io = KeywordIO()
keyword_io.read_keywords(self.iface.activeLayer())
except UnsupportedProviderError:
# noinspection PyUnresolvedReferences,PyCallByClass
QMessageBox.warning(
None,
self.tr('Unsupported layer type'),
self.tr(
'The layer you have selected cannot be used for '
'analysis because its data type is unsupported.'))
return
# End of fix for #776
# Fix for #793
except NoKeywordsFoundError:
# we will create them from scratch in the dialog
pass
# End of fix for #793
dialog = KeywordsDialog(
self.iface.mainWindow(),
self.iface,
self.dock_widget)
dialog.exec_() # modal
示例3: test_on_rad_postprocessing_toggled
def test_on_rad_postprocessing_toggled(self):
"""Test hazard radio button toggle behaviour works"""
layer = make_polygon_layer()
defaults = get_defaults()
dialog = KeywordsDialog(PARENT, IFACE, layer=layer)
button = dialog.radPostprocessing
button.setChecked(False)
button.click()
message = (
'Toggling the postprocessing radio did not add a '
'category to the keywords list.')
self.assertEqual(dialog.get_value_for_key(
'category'), 'postprocessing', message)
message = (
'Toggling the postprocessing radio did not add an '
'aggregation attribute to the keywords list.')
self.assertEqual(dialog.get_value_for_key(
defaults['AGGR_ATTR_KEY']), 'KAB_NAME', message)
message = (
'Toggling the postprocessing radio did not add a '
'female ratio attribute to the keywords list.')
self.assertEqual(dialog.get_value_for_key(
defaults['FEMALE_RATIO_ATTR_KEY']), dialog.global_default_string,
message)
message = (
'Toggling the postprocessing radio did not add a '
'female ratio default value to the keywords list.')
self.assertEqual(float(dialog.get_value_for_key(
defaults['FEMALE_RATIO_KEY'])), defaults['FEMALE_RATIO'], message)
示例4: showKeywordsEditor
def showKeywordsEditor(self):
"""Show the keywords editor.
This slot is called when the user clicks the keyword editor toolbar
icon or menu item associated with this plugin
.. see also:: :func:`Plugin.initGui`.
Args:
None.
Returns:
None.
Raises:
no exceptions explicitly raised.
"""
# import here only so that it is AFTER i18n set up
from safe_qgis.tools.keywords_dialog import KeywordsDialog
if self.iface.activeLayer() is None:
return
myDialog = KeywordsDialog(
self.iface.mainWindow(),
self.iface,
self.dockWidget)
myDialog.setModal(True)
myDialog.show()
示例5: test_on_dsb_female_ratio_default_value_changed
def test_on_dsb_female_ratio_default_value_changed(self):
"""Test hazard radio button toggle behaviour works"""
layer = make_polygon_layer()
defaults = get_defaults()
dialog = KeywordsDialog(PARENT, IFACE, layer=layer)
button = dialog.radPostprocessing
button.setChecked(False)
button.click()
female_ratio_box = dialog.cboFemaleRatioAttribute
# set to Don't use
index = female_ratio_box.findText(dialog.do_not_use_string)
message = (dialog.do_not_use_string + ' not found')
self.assertNotEqual(index, -1, message)
female_ratio_box.setCurrentIndex(index)
message = (
'Toggling the female ratio attribute combo to'
' "Don\'t use" did not add it to the keywords list.')
self.assertEqual(dialog.get_value_for_key(
defaults['FEMALE_RATIO_ATTR_KEY']), dialog.do_not_use_string,
message)
message = (
'Toggling the female ratio attribute combo to'
' "Don\'t use" did not disable dsbFemaleRatioDefault.')
is_enabled = dialog.dsbFemaleRatioDefault.isEnabled()
assert not is_enabled, message
message = (
'Toggling the female ratio attribute combo to'
' "Don\'t use" did not remove the keyword.')
assert (dialog.get_value_for_key(defaults['FEMALE_RATIO']) is None), \
message
# set to TEST_REAL
index = female_ratio_box.findText('TEST_REAL')
message = 'TEST_REAL not found'
assert (index != -1), message
female_ratio_box.setCurrentIndex(index)
message = (
'Toggling the female ratio attribute combo to "TEST_REAL"'
' did not add it to the keywords list.')
assert dialog.get_value_for_key(
defaults['FEMALE_RATIO_ATTR_KEY']) == 'TEST_REAL', message
message = (
'Toggling the female ratio attribute combo to "TEST_REAL"'
' did not disable dsbFemaleRatioDefault.')
is_enabled = dialog.dsbFemaleRatioDefault.isEnabled()
assert not is_enabled, message
message = (
'Toggling the female ratio attribute combo to "TEST_REAL"'
' did not remove the keyword.')
assert (dialog.get_value_for_key(defaults['FEMALE_RATIO']) is
None), message
示例6: test_on_radHazard_toggled
def test_on_radHazard_toggled(self):
"""Test hazard radio button toggle behaviour works"""
myDialog = KeywordsDialog(PARENT, IFACE)
myButton = myDialog.radHazard
myButton.setChecked(False)
myButton.click()
myMessage = ('Toggling the hazard radio did not add a category '
'to the keywords list.')
assert myDialog.get_value_for_key('category') == 'hazard', myMessage
示例7: test_getValueForKey
def test_getValueForKey(self):
"""Test get value for key works"""
makePadangLayer()
myDialog = KeywordsDialog(PARENT, IFACE)
myExpectedValue = 'hazard'
myValue = myDialog.get_value_for_key('category')
myMessage = ('\nExpected key value of %s\nGot %s' %
(myExpectedValue, myValue))
assert myValue == myExpectedValue, myMessage
示例8: test_reset
def test_reset(self):
"""Test form reset works."""
dialog = KeywordsDialog(PARENT, IFACE)
dialog.leTitle.setText('Foo')
dialog.reset(False)
expected_result = ''
result = dialog.leTitle.text()
message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
self.assertEqual(result, expected_result, message)
示例9: test_on_radHazard_toggled
def test_on_radHazard_toggled(self):
"""Test hazard radio button toggle behaviour works"""
myDialog = KeywordsDialog(PARENT, IFACE)
myButton = myDialog.radHazard
myButton.setChecked(False)
# noinspection PyArgumentList
QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
myMessage = ('Toggling the hazard radio did not add a category '
'to the keywords list.')
assert myDialog.get_value_for_key('category') == 'hazard', myMessage
示例10: test_reset
def test_reset(self):
"""Test form reset works"""
myDialog = KeywordsDialog(PARENT, IFACE)
myDialog.leTitle.setText('Foo')
myDialog.reset(False)
myExpectedResult = ''
myResult = myDialog.leTitle.text()
myMessage = ('\nGot: %s\nExpected: %s\n' %
(myResult, myExpectedResult))
assert myResult == myExpectedResult, myMessage
示例11: Xtest_on_radExposure_toggled
def Xtest_on_radExposure_toggled(self):
"""Test exposure radio button toggle behaviour works"""
# Cannot get this test to work, but it works fine in the safe_qgis
myDialog = KeywordsDialog(PARENT, IFACE)
myButton = myDialog.radExposure
myButton.setChecked(False)
myButton.click()
myMessage = ('Toggling the exposure radio did not add a category '
'to the keywords list.')
assert myDialog.get_value_for_key('category') == 'exposure', myMessage
示例12: test_on_rad_hazard_toggled
def test_on_rad_hazard_toggled(self):
"""Test hazard radio button toggle behaviour works"""
dialog = KeywordsDialog(PARENT, IFACE)
button = dialog.radHazard
button.setChecked(False)
button.click()
message = (
'Toggling the hazard radio did not add a category '
'to the keywords list.')
self.assertEqual(
dialog.get_value_for_key('category'), 'hazard',
message)
示例13: show_keywords_editor
def show_keywords_editor(self):
"""Show the keywords editor."""
# import here only so that it is AFTER i18n set up
from safe_qgis.tools.keywords_dialog import KeywordsDialog
if self.iface.activeLayer() is None:
return
myDialog = KeywordsDialog(
self.iface.mainWindow(),
self.iface,
self.dockWidget)
myDialog.exec_() # modal
示例14: test_remove_item_by_value
def test_remove_item_by_value(self):
"""Test remove item by its value works."""
make_padang_layer()
dialog = KeywordsDialog(PARENT, IFACE)
dialog.remove_item_by_value('hazard')
keywords = dialog.get_keywords()
expected_keywords = {
'source': 'USGS',
'title': 'An earthquake in Padang like in 2009',
'subcategory': 'earthquake',
'unit': 'MMI'}
self.assertEqual(keywords, expected_keywords)
示例15: test_addWarningsForColons
def test_addWarningsForColons(self):
"""Test add entry to list works"""
myDialog = KeywordsDialog(PARENT, IFACE)
myDialog.reset(False)
myDialog.add_list_entry('bar', 'fo:o')
myResult = myDialog.get_value_for_key('bar')
myExpectedResult = 'fo.o'
myMessage = ('\nGot: %s\nExpected: %s\n' %
(myResult, myExpectedResult))
#print 'Dict', myDialog.getKeywords()
assert myResult == myExpectedResult, myMessage
#
# Check the user gets a message if they put colons in the value
#
myExpectedResult = 'Colons are not allowed, replaced with "."'
myResult = str(myDialog.lblMessage.text())
myMessage = ('lblMessage error \nGot: %s\nExpected: %s\n' %
(myResult, myExpectedResult))
#print 'Dict', myDialog.getKeywords()
assert myResult == myExpectedResult, myMessage
#
# Check the user gets a message if they put colons in the key
#
myDialog.add_list_entry('ba:r', 'foo')
myExpectedResult = 'Colons are not allowed, replaced with "."'
myResult = str(myDialog.lblMessage.text())
myMessage = ('lblMessage error \nGot: %s\nExpected: %s\n' %
(myResult, myExpectedResult))
#print 'Dict', myDialog.getKeywords()
assert myResult == myExpectedResult, myMessage