QGIS doesn't update some snapping options from Python

If you want to update the options you see in Settings > Snapping Options..., you can use the setSnapSettingsForLayer() function from the QgsProject Class:

proj=QgsProject.instance()
layer = qgis.utils.iface.activeLayer()
proj.setSnapSettingsForLayer(layer.id(), True, 0, 1, 10, True)

Note that although you're using the active layer to set the snapping options, this will apply to all layers in your project.


Interestingly, your method does not update any GUI options in Settings > Options > Digitizing > Snapping nor in Settings > Options > Advanced> Qgis > digitizing. But if you use the following, these GUI options will be updated but not in Settings > Snapping Options:

from PyQt4.QtCore import QSettings
QSettings().setValue('QGIS/digitizing/default_snap_mode', 'to vertex and segment')
QSettings().setValue('QGIS/digitizing/default_snapping_tolerance', 10)

But I'm not in a position to say whether or not it's a bug.



EDIT:

I am also using QGIS 2.14.3-Essen for Win7 64-bit.

I did some more testing also, it seems that for me atleast, the Settings > Snapping Options... interface only gets updated when I either use the setSnapSettingsForLayer class or close the interface and open it again. This includes testing the checkboxes the same way you have done.

Therefore, if you want to use the advanced snapping options, try:

proj = QgsProject.instance()
proj.writeEntry('Digitizing', 'SnappingMode', 'advanced') 
layer = qgis.utils.iface.activeLayer()
proj.setSnapSettingsForLayer(layer.id(), True, 0, 1, 30, True)

Note that you will need to select each layer and run the last 2 lines to update the settings in the advanced interface.

It seems that the setSnapSettingsForLayer class only registers when using the advanced snapping options because if you use the following for either current_layer and all_layers, any values set using the setSnapSettingsForLayer class seems to be ignored but the interface will be updated with the values you set using proj.writeEntry():

proj = QgsProject.instance()
proj.writeEntry('Digitizing', 'SnappingMode', 'all_layers') 
proj.writeEntry('Digitizing','DefaultSnapTolerance', 25.0)
layer = qgis.utils.iface.activeLayer()
proj.setSnapSettingsForLayer(layer.id(), True, 0, 0, 0, True)

Because now if I type the following like you have done:

>>> proj.readNumEntry('Digitizing','DefaultSnapTolerance')
25

Weird behavour...