Advertisement
Guest User

qgis_python_colose

a guest
Oct 1st, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. # Console Python - QGIS
  2.  
  3. from PyQt4 import QtGui
  4.  
  5. def printEnable():
  6.     print "Enable"
  7.  
  8. li = iface.legendInterface()
  9. layer = iface.activeLayer()
  10. if layer.type() == QgsMapLayer.VectorLayer:
  11.     action = QtGui.QAction( u"My Action", iface.legendInterface() )
  12.     action.triggered.connect( printEnable )
  13.     arg = ( action, "My Plugin Menu", "id1", QgsMapLayer.VectorLayer, False  )
  14.     li.addLegendLayerAction( *arg )
  15.     li.addLegendLayerActionForLayer( action, layer )
  16.  
  17. # Try Disable
  18. #action.setEnabled(False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement