本文整理匯總了Python中qgis.PyQt.QtCore.QUuid.createUuid方法的典型用法代碼示例。如果您正苦於以下問題:Python QUuid.createUuid方法的具體用法?Python QUuid.createUuid怎麽用?Python QUuid.createUuid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.PyQt.QtCore.QUuid
的用法示例。
在下文中一共展示了QUuid.createUuid方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testDefaultAction
# 需要導入模塊: from qgis.PyQt.QtCore import QUuid [as 別名]
# 或者: from qgis.PyQt.QtCore.QUuid import createUuid [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())
示例2: testRemoveActions
# 需要導入模塊: from qgis.PyQt.QtCore import QUuid [as 別名]
# 或者: from qgis.PyQt.QtCore.QUuid import createUuid [as 別名]
def testRemoveActions(self):
""" test removing actions """
# add an action
self.manager.addAction(QgsAction.GenericPython, 'test_action', 'i=1')
# clear the manager and check that it's empty
self.manager.clearActions()
self.assertEqual(self.manager.actions(), [])
# add some actions
id1 = self.manager.addAction(QgsAction.GenericPython, 'test_action', 'i=1')
id2 = self.manager.addAction(QgsAction.GenericPython, 'test_action2', 'i=2')
id3 = self.manager.addAction(QgsAction.GenericPython, 'test_action3', 'i=3')
# remove non-existent action
self.manager.removeAction(QUuid.createUuid())
# remove them one by one
self.manager.removeAction(id2)
self.assertEqual(len(self.manager.actions()), 2)
self.assertEqual(self.manager.action(id1).name(), 'test_action')
self.assertEqual(self.manager.action(id3).name(), 'test_action3')
self.manager.removeAction(id1)
self.assertEqual(len(self.manager.actions()), 1)
self.assertEqual(self.manager.action(id3).name(), 'test_action3')
self.manager.removeAction(id3)
self.assertEqual(len(self.manager.actions()), 0)
示例3: testDefaultAction
# 需要導入模塊: from qgis.PyQt.QtCore import QUuid [as 別名]
# 或者: from qgis.PyQt.QtCore.QUuid import createUuid [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())