[GIS] Triggering QGIS action when plugin button is clicked

pyqgisqgis-plugins

I tried calling the select free hand tool by below snippet of code.

iface.actionSelectFreehand().trigger()

I dnt have any idea how to call this when i am pressing a button in GUI. my gui is attached below

enter image description here

When Select Area from Map is pressed i want the select free hand to be called in my plugin. FYI the name of Select Area from Map in QTDEsigner is areapushbutton.

Best Answer

You don't really seem to have read at least one of the resources I collected for you in Layer properties dialog in my QGIS plugin.

If you open, for example this one, you'll see the answer to your question:

button.clicked.connect(self.onClicked)

In your case it would be something like (you might need to edit it to match your plugin structure):

self.areapushbutton.clicked.connect( self.iface.actionSelectFreehand().trigger )
Related Question