[Qgis-developer] Ending edit shapefile in Python plugin

Benoit de Cabissole benoit at exigesa.com
Mon Aug 23 16:52:23 EDT 2010


Hi Developers,

I'm playing with a plugin that allows editing of a shapefile.
When editing is finished, I want to save (commit) the changes to disk, so I
use:

  if self.theLayer.startEditing():

     #do edits here

     if self.theLayer.commitChanges():
         #all ok
         showOKMessage()
     else:
         #error
         showErrorMessage()
     self.iface.mapCanvas().refresh()

Now, the OK message is displayed and the icon of the vector, in the legend,
is changed from "in edit mode" (little black pen)  to "normal mode" (points
icon in my case). So far so good. BUT, the edit toolbar stays in "edit mode"
and I have to press twice the "toggle edit" button to sync the toolbar and
the legend.

Question is: is there a way to sync the edit toolbar on successful
commitChanges()?

I've also tried not to use commitChanges() but instead use
beginEditCommand/endEditCommand/mapCanvas().refresh() but those leave the
legend and edit toolbar in "edit mode" and I have to commit the changes
manually by clicking on the "toggle edit" button.


Any hints?

Chers,
Benoit




More information about the Qgis-developer mailing list