3

I have built my custom plugin by name ABTD plugin I have installed the plugin named real centroid in qgis. Now, I want to add a button to my plugin which will in turn open the "real centroid" plugin dialog box which has been installed by me in QGIS.

Is it possible? enter image description here

1 Answer 1

8

First, you need to review the plugin's script, find how to call it. For realCentroid, use the following lines for the click event of the button in your script:

def button_clicked(self):
    from realcentroid.realcentroid import RealCentroid
    rc = RealCentroid(self.iface)
    rc.run()

If you want to test it in QGIS Python Console, try this:

from realcentroid.realcentroid import RealCentroid
rc = RealCentroid(iface)
rc.run()

How to build the import part:

In from realcentroid.realcentroid import RealCentroid

  • The first realcentroid is the folder name of the plugin.

    enter image description here

  • The second realcentroid is the main module that __init.py__ uses.

    enter image description here

  • RealCentroid is the main class in the main module.

    enter image description here

run method is not mandatory. We call it because run method in RealCentroid class contains the line that opens the plugin dialog window. Therefore, you must review the main class to find how to open that dialog window. It depends.

2
  • Thank you it worked. But i had one doubt - how to find its calling name?
    – sahilk
    Oct 17, 2022 at 10:00
  • I've added more explanation. Oct 17, 2022 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.