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


Python QgsAction.id方法代碼示例

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


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

示例1: testDefaultAction

# 需要導入模塊: from qgis.core import QgsAction [as 別名]
# 或者: from qgis.core.QgsAction import id [as 別名]
    def testDefaultAction(self):
        """ test default action for layer"""

        self.manager.clearActions()
        action1 = QgsAction(QgsAction.GenericPython, 'test_action', '', 'i=1', False, actionScopes={'Feature'})
        self.manager.addAction(action1)
        action2 = QgsAction(QgsAction.GenericPython, 'test_action2', 'i=2')
        self.manager.addAction(action2)

        # initially should be not set
        self.assertFalse(self.manager.defaultAction('Feature').isValid())

        # set bad default action
        self.manager.setDefaultAction('Feature', QUuid.createUuid())
        self.assertFalse(self.manager.defaultAction('Feature').isValid())

        # set good default action
        self.manager.setDefaultAction('Feature', action1.id())
        self.assertTrue(self.manager.defaultAction('Feature').isValid())
        self.assertEqual(self.manager.defaultAction('Feature').id(), action1.id())
        self.assertNotEqual(self.manager.defaultAction('Feature').id(), action2.id())

        # if default action is removed, should be reset to -1
        self.manager.clearActions()
        self.assertFalse(self.manager.defaultAction('Feature').isValid())
開發者ID:SrNetoChan,項目名稱:Quantum-GIS,代碼行數:27,代碼來源:test_qgsactionmanager.py

示例2: testAddAction

# 需要導入模塊: from qgis.core import QgsAction [as 別名]
# 或者: from qgis.core.QgsAction import id [as 別名]
    def testAddAction(self):
        """ Test adding actions """

        # should be empty to start with
        self.assertEqual(self.manager.actions(), [])

        # add an action
        action1 = QgsAction(QgsAction.GenericPython, 'Test Action', 'i=1')
        self.manager.addAction(action1)
        self.assertEqual(len(self.manager.actions()), 1)
        self.assertEqual(self.manager.actions()[0].type(), QgsAction.GenericPython)
        self.assertEqual(self.manager.actions()[0].name(), 'Test Action')
        self.assertEqual(self.manager.actions()[0].command(), 'i=1')

        # add another action
        action2 = QgsAction(QgsAction.Windows, 'Test Action2', 'i=2')
        self.manager.addAction(action2)
        self.assertEqual(len(self.manager.actions()), 2)
        self.assertEqual(self.manager.action(action2.id()).type(), QgsAction.Windows)
        self.assertEqual(self.manager.action(action2.id()).name(), 'Test Action2')
        self.assertEqual(self.manager.action(action2.id()).command(), 'i=2')

        id3 = self.manager.addAction(QgsAction.Generic, 'Test Action3', 'i=3')
        self.assertEqual(len(self.manager.actions()), 3)
        self.assertEqual(self.manager.action(id3).type(), QgsAction.Generic)
        self.assertEqual(self.manager.action(id3).name(), 'Test Action3')
        self.assertEqual(self.manager.action(id3).command(), 'i=3')
開發者ID:SrNetoChan,項目名稱:Quantum-GIS,代碼行數:29,代碼來源:test_qgsactionmanager.py

示例3: testDefaultAction

# 需要導入模塊: from qgis.core import QgsAction [as 別名]
# 或者: from qgis.core.QgsAction import id [as 別名]
    def testDefaultAction(self):
        """ test default action for layer"""

        self.manager.clearActions()
        action1 = QgsAction(QgsAction.GenericPython, "test_action", "", "i=1", False, actionScopes={"Feature"})
        self.manager.addAction(action1)
        action2 = QgsAction(QgsAction.GenericPython, "test_action2", "i=2")
        self.manager.addAction(action2)

        # initially should be not set
        self.assertFalse(self.manager.defaultAction("Feature").isValid())

        # set bad default action
        self.manager.setDefaultAction("Feature", QUuid.createUuid())
        self.assertFalse(self.manager.defaultAction("Feature").isValid())

        # set good default action
        self.manager.setDefaultAction("Feature", action1.id())
        self.assertTrue(self.manager.defaultAction("Feature").isValid())
        self.assertEquals(self.manager.defaultAction("Feature").id(), action1.id())
        self.assertNotEquals(self.manager.defaultAction("Feature").id(), action2.id())

        # if default action is removed, should be reset to -1
        self.manager.clearActions()
        self.assertFalse(self.manager.defaultAction("Feature").isValid())
開發者ID:medspx,項目名稱:QGIS,代碼行數:27,代碼來源:test_qgsactionmanager.py


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