[GIS] PyQGIS: How to send signal if layer is currently in edit mode

pyqgispythonqgis

I'm looking for a way to send a signal if a layer is in editing mode. I tried editingStarted(), but it wasn't working. I'd like to do something along the lines of the what I have below, but can't find it in the API (where I'm looking: http://qgis.org/api/classQgsVectorLayer.html#a476eaf6ec8f2a45e285e963bcacedcc2)

qgis.utils.iface.setActiveLayer(myLayer)
#capslock is in place of the method i'm searching
if myLayer.ISINEDITMODE() == False:
    qgis.utils.iface.actionToggleEditing().trigger()

Best Answer

You want the isEditable method:

if not myLayer.isEditable():
    iface.actionToggleEditing.trigger()
Related Question