• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python keywords_dialog.KeywordsDialog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了KeywordsDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:7,代码来源:test_keywords_dialog.py


示例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
开发者ID:borysiasty,项目名称:inasafe,代码行数:33,代码来源:plugin.py


示例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)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:33,代码来源:test_keywords_dialog.py


示例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()
开发者ID:gsuhartono,项目名称:inasafe,代码行数:28,代码来源:plugin.py


示例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
开发者ID:cccs-ip,项目名称:inasafe,代码行数:58,代码来源:test_keywords_dialog.py


示例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
开发者ID:vdeparday,项目名称:inasafe,代码行数:9,代码来源:test_keywords_dialog.py


示例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
开发者ID:feyeandal,项目名称:inasafe,代码行数:9,代码来源:test_keywords_dialog.py


示例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)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:9,代码来源:test_keywords_dialog.py


示例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
开发者ID:feyeandal,项目名称:inasafe,代码行数:10,代码来源:test_keywords_dialog.py


示例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
开发者ID:feyeandal,项目名称:inasafe,代码行数:10,代码来源:test_keywords_dialog.py


示例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
开发者ID:vdeparday,项目名称:inasafe,代码行数:11,代码来源:test_keywords_dialog.py


示例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)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:12,代码来源:test_keywords_dialog.py


示例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
开发者ID:danylaksono,项目名称:inasafe,代码行数:12,代码来源:plugin.py


示例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)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:13,代码来源:test_keywords_dialog.py


示例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
开发者ID:feyeandal,项目名称:inasafe,代码行数:30,代码来源:test_keywords_dialog.py


示例16: test_add_warnings_for_colons

 def test_add_warnings_for_colons(self):
     """Test add entry to list works."""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.add_list_entry('bar', 'fo:o')
     result = dialog.get_value_for_key('bar')
     expected_result = 'fo.o'
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
     #
     # Check the user gets a message if they put colons in the value
     #
     expected_result = 'Colons are not allowed, replaced with "."'
     result = str(dialog.lblMessage.text())
     message = (
         'lblMessage error \nGot: %s\nExpected: %s\n' %
         (result, expected_result))
     self.assertEqual(result, expected_result, message)
     #
     # Check the user gets a message if they put colons in the key
     #
     dialog.add_list_entry('ba:r', 'foo')
     expected_result = 'Colons are not allowed, replaced with "."'
     result = str(dialog.lblMessage.text())
     message = (
         'lblMessage error \nGot: %s\nExpected: %s\n' %
         (result, expected_result))
     self.assertEqual(result, expected_result, message)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:28,代码来源:test_keywords_dialog.py


示例17: test_load_state_from_keywords

    def test_load_state_from_keywords(self):
        """Test load state from keywords works."""
        layer = make_padang_layer()
        dialog = KeywordsDialog(PARENT, IFACE, layer=layer)
        dialog.load_state_from_keywords()
        keywords = dialog.get_keywords()

        expected_keywords = {
            'title': 'An earthquake in Padang like in 2009',
            'category': 'hazard',
            'source': 'USGS',
            'subcategory': 'earthquake',
            'unit': 'MMI'}
        self.assertEqual(keywords, expected_keywords)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:14,代码来源:test_keywords_dialog.py


示例18: test_removeItemByValue

    def test_removeItemByValue(self):
        """Test remove item by its value works"""
        makePadangLayer()
        myDialog = KeywordsDialog(PARENT, IFACE)
        myDialog.remove_item_by_value('hazard')

        myKeywords = myDialog.get_keywords()
        myExpectedKeywords = {'source': 'USGS',
                              'title': 'An earthquake in Padang like in 2009',
                              'subcategory': 'earthquake',
                              'unit': 'MMI'}
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myKeywords, myExpectedKeywords))

        assert myKeywords == myExpectedKeywords, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:15,代码来源:test_keywords_dialog.py


示例19: test_layer_without_keywords

 def test_layer_without_keywords(self):
     """Test load state from keywords works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myLayer = make_keywordless_layer()
     myDialog.layer = myLayer
     myDialog.load_state_from_keywords()
     myKeywords = myDialog.get_keywords()
     #check that a default title is given (see
     #https://github.com/AIFDR/inasafe/issues/111)
     myExpectedKeywords = {
         'category': 'exposure',
         'title': 'Keywordless Layer'}
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myKeywords, myExpectedKeywords))
     assert myKeywords == myExpectedKeywords, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:15,代码来源:test_keywords_dialog.py


示例20: test_on_pbn_remove_clicked

    def test_on_pbn_remove_clicked(self):
        """Test pressing remove works on key list"""
        dialog = KeywordsDialog(PARENT, IFACE)
        dialog.reset(False)

        result = dialog.lstKeywords.count()
        expected_result = 0
        message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
        self.assertEqual(result, expected_result, message)

        dialog.add_list_entry('bar', 'foo')
        result = dialog.lstKeywords.count()
        expected_result = 1
        message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
        self.assertEqual(result, expected_result, message)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:15,代码来源:test_keywords_dialog.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python clipper.clip_layer函数代码示例发布时间:2022-05-27
下一篇:
Python safe_interface.unique_filename函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap