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

Python keywords_dialog.KeywordsDialog类代码示例

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

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



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

示例1: 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.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:maning,项目名称:inasafe,代码行数:28,代码来源:plugin.py


示例2: test_getValueForKey

 def test_getValueForKey(self):
     """Test get value for key works"""
     makePadangLayer()
     myDialog = KeywordsDialog(PARENT, IFACE)
     myExpectedValue = 'hazard'
     myValue = myDialog.getValueForKey('category')
     myMessage = ('\nExpected key value of %s\nGot %s' %
                  (myExpectedValue, myValue))
     assert myValue == myExpectedValue, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:9,代码来源:test_keywords_dialog.py


示例3: 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)
     QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
     myMessage = ('Toggling the hazard radio did not add a category '
                  'to the keywords list.')
     assert myDialog.getValueForKey('category') == 'hazard', myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:9,代码来源:test_keywords_dialog.py


示例4: 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:fivejjs,项目名称:inasafe,代码行数:10,代码来源:test_keywords_dialog.py


示例5: 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)
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myMessage = ('Toggling the exposure radio did not add a category '
                     'to the keywords list.')
        assert myDialog.getValueForKey('category') == 'exposure', myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:11,代码来源:test_keywords_dialog.py


示例6: test_addWarningsForColons

 def test_addWarningsForColons(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.addListEntry('bar', 'fo:o')
     myResult = myDialog.getValueForKey('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.addListEntry('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:fivejjs,项目名称:inasafe,代码行数:30,代码来源:test_keywords_dialog.py


示例7: test_checkStateWhenKeywordsAbsent

 def test_checkStateWhenKeywordsAbsent(self):
     """Test load state from keywords works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myLayer = makeKeywordlessLayer()
     myDialog.layer = myLayer
     myDialog.loadStateFromKeywords()
     myKeywords = myDialog.getKeywords()
     #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:fivejjs,项目名称:inasafe,代码行数:14,代码来源:test_keywords_dialog.py


示例8: test_removeItemByValue

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

        myKeywords = myDialog.getKeywords()
        myExpectedKeywords = {'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:takmid,项目名称:inasafe,代码行数:14,代码来源:test_keywords_dialog.py


示例9: test_loadStateFromKeywords

    def test_loadStateFromKeywords(self):
        """Test load state from keywords works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myLayer = makePadangLayer()
        myDialog.layer = myLayer
        myDialog.loadStateFromKeywords()
        myKeywords = myDialog.getKeywords()

        myExpectedKeywords = {'title': 'An earthquake in Padang like in 2009',
                              'category': 'hazard',
                              'subcategory': 'earthquake',
                              'unit': 'MMI'}
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myKeywords, myExpectedKeywords))
        assert myKeywords == myExpectedKeywords, myMessage
开发者ID:takmid,项目名称:inasafe,代码行数:15,代码来源:test_keywords_dialog.py


示例10: test_on_cboSubcategory_currentIndexChanged

 def test_on_cboSubcategory_currentIndexChanged(self):
     """Test subcategory combo change event works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myButton = myDialog.radHazard
     myButton.setChecked(True)
     myButton = myDialog.radExposure
     QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
     myCombo = myDialog.cboSubcategory
     QTest.mouseClick(myCombo, QtCore.Qt.LeftButton)
     QTest.keyClick(myCombo, QtCore.Qt.Key_Up)
     QTest.keyClick(myCombo, QtCore.Qt.Key_Enter)
     myMessage = ('Changing the subcategory did not add '
                  'to the keywords list for %s' %
                  myCombo.currentText())
     myKey = myDialog.getValueForKey('subcategory')
     assert myKey is not None, myMessage
     assert myKey in str(myCombo.currentText()), myMessage
开发者ID:takmid,项目名称:inasafe,代码行数:17,代码来源:test_keywords_dialog.py


示例11: test_on_pbnRemove_clicked

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

        myResult = myDialog.lstKeywords.count()
        myExpectedResult = 0
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))
        #print 'Dict', myDialog.getKeywords()
        assert myResult == myExpectedResult, myMessage

        myDialog.addListEntry('bar', 'foo')
        myResult = myDialog.lstKeywords.count()
        myExpectedResult = 1
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))
        #print 'Dict', myDialog.getKeywords()
        assert myResult == myExpectedResult, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:19,代码来源:test_keywords_dialog.py


示例12: test_on_dsbFemaleRatioDefault_valueChanged

    def test_on_dsbFemaleRatioDefault_valueChanged(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = getDefaults()
        myDialog = KeywordsDialog(PARENT, IFACE, theLayer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myFemaleRatioAttrBox = myDialog.cboFemaleRatioAttribute

        #set to Don't use
        myIndex = myFemaleRatioAttrBox.findText(
            myDialog.tr('Don\'t use'))
        myMessage = (myDialog.tr('Don\'t use') + ' not found')
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not add it to the keywords list.')
        assert myDialog.getValueForKey(
            myDefaults['FEM_RATIO_ATTR_KEY']) ==\
               myDialog.tr('Don\'t use'), myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not remove the keyword.')
        assert (myDialog.getValueForKey(myDefaults['FEM_RATIO']) is
            None), myMessage

        #set to TEST_REAL
        myIndex = myFemaleRatioAttrBox.findText('TEST_REAL')
        myMessage = ('TEST_REAL not found')
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not add it to the keywords list.')
        assert myDialog.getValueForKey(
            myDefaults['FEM_RATIO_ATTR_KEY']) == 'TEST_REAL', myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not remove the keyword.')
        assert (myDialog.getValueForKey(myDefaults['FEM_RATIO']) is
                None), myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:53,代码来源:test_keywords_dialog.py


示例13: test_addKeywordWhenPressOkButton

    def test_addKeywordWhenPressOkButton(self):
        """Test add keyword when ok button is pressed."""
        #_, myFile = makePadangLayerClone()
        makePadangLayerClone()
        myDialog = KeywordsDialog(PARENT, IFACE)

        myDialog.radUserDefined.setChecked(True)
        myDialog.leKey.setText('foo')
        myDialog.leValue.setText('bar')
        okButton = myDialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        QTest.mouseClick(okButton, QtCore.Qt.LeftButton)

        # delete temp file
        # removeTempFile(myFile)

        myExpectedResult = 'bar'
        myResult = myDialog.getValueForKey('foo')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))
        assert myExpectedResult == myResult, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:20,代码来源:test_keywords_dialog.py


示例14: test_on_radPostprocessing_toggled

    def test_on_radPostprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = getDefaults()
        myDialog = KeywordsDialog(PARENT, IFACE, theLayer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myMessage = ('Toggling the postprocessing radio did not add a '
                     'category to the keywords list.')
        assert myDialog.getValueForKey(
            'category') == 'postprocessing', myMessage

        myMessage = ('Toggling the postprocessing radio did not add an '
                     'aggregation attribute to the keywords list.')
        assert myDialog.getValueForKey(
            myDefaults['AGGR_ATTR_KEY']) == 'KAB_NAME', myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio attribute to the keywords list.')

        assert myDialog.getValueForKey(
            myDefaults['FEM_RATIO_ATTR_KEY']) == \
               myDialog.tr('Use default'), myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio default value to the keywords list.')
        assert float(myDialog.getValueForKey(
            myDefaults['FEM_RATIO_KEY'])) == \
               myDefaults['FEM_RATIO'], myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:30,代码来源:test_keywords_dialog.py


示例15: test_setSubcategoryList

    def test_setSubcategoryList(self):
        """Test set subcategory list works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myList = OrderedDict([('population [density]',
                                      'population [density]'),
                                     ('population [count]',
                                      'population [count]'),
                                     ('building',
                                      'building'),
                                     ('building [osm]',
                                      'building [osm]'),
                                     ('building [sigab]',
                                      'building [sigab]'),
                                     ('roads',
                                      'roads')])
        mySelectedItem = 'building'
        myDialog.setSubcategoryList(myList, mySelectedItem)
        myResult = str(myDialog.cboSubcategory.currentText())
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, mySelectedItem))

        assert myResult == mySelectedItem, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:22,代码来源:test_keywords_dialog.py


示例16: test_removeItemByKey

 def test_removeItemByKey(self):
     """Test remove item by its key works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.addListEntry('bar', 'foo')
     myDialog.removeItemByKey('bar')
     myResult = myDialog.lstKeywords.count()
     myExpectedResult = 0
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:12,代码来源:test_keywords_dialog.py


示例17: test_setCategory

 def test_setCategory(self):
     """Test set category works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.setCategory('hazard')
     myExpectedResult = 'hazard'
     myResult = myDialog.getValueForKey('category')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:11,代码来源:test_keywords_dialog.py


示例18: test_addListEntry

 def test_addListEntry(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.addListEntry('bar', 'foo')
     myResult = myDialog.getValueForKey('bar')
     myExpectedResult = 'foo'
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:11,代码来源:test_keywords_dialog.py


示例19: test_on_pbnAddToList2_clicked

 def test_on_pbnAddToList2_clicked(self):
     """Test adding an item to the list using user defened form works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.radUserDefined.setChecked(True)
     myDialog.leKey.setText('foo')
     myDialog.leValue.setText('bar')
     myExpectedResult = 'bar'
     myDialog.lePredefinedValue.setText(myExpectedResult)
     # Work around for commented out line below
     myDialog.on_pbnAddToList2_clicked()
     #QTest.mouseClick(myDialog.pbnAddToList2, QtCore.Qt.LeftButton)
     myResult = myDialog.getValueForKey('foo')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:17,代码来源:test_keywords_dialog.py


示例20: test_on_pbnAddToList1_clicked

    def test_on_pbnAddToList1_clicked(self):
        """Test adding an item to the list using predefined form works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myDialog.reset(False)
        myDialog.radPredefined.setChecked(True)
        myDialog.cboKeyword.setCurrentIndex(2)
        myExpectedResult = 'foo'
        myDialog.lePredefinedValue.setText(myExpectedResult)
        # Work around for commented out line below
        myDialog.on_pbnAddToList1_clicked()
        #QTest.mouseClick(myDialog.pbnAddToList1, QtCore.Qt.LeftButton)
        myResult = myDialog.getValueForKey('datatype')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))

        assert myResult == myExpectedResult, myMessage
开发者ID:fivejjs,项目名称:inasafe,代码行数:16,代码来源:test_keywords_dialog.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python map.Map类代码示例发布时间:2022-05-27
下一篇:
Python keyword_io.KeywordIO类代码示例发布时间: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