當前位置: 首頁>>代碼示例>>Python>>正文


Python QgsSourceSelectProviderRegistry.addProvider方法代碼示例

本文整理匯總了Python中qgis.gui.QgsSourceSelectProviderRegistry.addProvider方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsSourceSelectProviderRegistry.addProvider方法的具體用法?Python QgsSourceSelectProviderRegistry.addProvider怎麽用?Python QgsSourceSelectProviderRegistry.addProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qgis.gui.QgsSourceSelectProviderRegistry的用法示例。


在下文中一共展示了QgsSourceSelectProviderRegistry.addProvider方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _testRegistry

# 需要導入模塊: from qgis.gui import QgsSourceSelectProviderRegistry [as 別名]
# 或者: from qgis.gui.QgsSourceSelectProviderRegistry import addProvider [as 別名]
    def _testRegistry(self, registry):

        registry.addProvider(ConcreteSourceSelectProvider())
        registry.addProvider(ConcreteSourceSelectProvider2())

        # Check order
        self.assertEqual(['MyTestProviderKey', 'MyName'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        registry = QgsSourceSelectProviderRegistry()
        registry.addProvider(ConcreteSourceSelectProvider())
        registry.addProvider(ConcreteSourceSelectProvider2())

        # Check order
        self.assertEqual(['MyTestProviderKey', 'MyName'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        # Get provider by name
        self.assertTrue(registry.providerByName('MyTestProviderKey'))
        self.assertTrue(registry.providerByName('MyName'))

        # Get not existent by name
        self.assertFalse(registry.providerByName('Oh This Is Missing!'))

        # Get providers by data provider key
        self.assertGreater(len(registry.providersByKey('MyTestProviderKey')), 0)
        self.assertGreater(len(registry.providersByKey('MyTestProviderKey2')), 0)

        # Get not existent by key
        self.assertEqual(len(registry.providersByKey('Oh This Is Missing!')), 0)
開發者ID:Cracert,項目名稱:Quantum-GIS,代碼行數:30,代碼來源:test_qgssourceselectprovider.py

示例2: testRemoveProvider

# 需要導入模塊: from qgis.gui import QgsSourceSelectProviderRegistry [as 別名]
# 或者: from qgis.gui.QgsSourceSelectProviderRegistry import addProvider [as 別名]
    def testRemoveProvider(self):
        registry = QgsSourceSelectProviderRegistry()
        registry.addProvider(ConcreteSourceSelectProvider())
        registry.addProvider(ConcreteSourceSelectProvider2())
        self.assertEqual(['MyTestProviderKey', 'MyName'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        self.assertTrue(registry.removeProvider(registry.providerByName('MyName')))
        self.assertEqual(['MyTestProviderKey'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        self.assertTrue(registry.removeProvider(registry.providerByName('MyTestProviderKey')))
        self.assertEqual([], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])
開發者ID:Cracert,項目名稱:Quantum-GIS,代碼行數:13,代碼來源:test_qgssourceselectprovider.py


注:本文中的qgis.gui.QgsSourceSelectProviderRegistry.addProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。