Sunday, 3 December 2017

pyqgis - Where is the QGIS API action for "deselect"?



Where is the QGIS action for the “deselect” toolbutton in the 'Attributes" toolbar? I do not see this action in the QgisInterface class or do not recognize it by name. Is it missing from iface?


I'd like to use this action in a plugin directly instead of the button on the toolbar.



Answer



You can get the attributes toolbar and iterate through its actions (buttons) until you get the "deselect" one. Then you can trigger it.


Try this in your QGIS Python console:


for a in iface.attributesToolBar().actions(): 
if a.objectName() == 'mActionDeselectAll':
a.trigger()
break

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...