2

I've created a script with python console on QGIS and an interface for my plugin with Qt Designer with QGIS 2.14.0 custom widgets.

I would like to connect my sript with the interface but I can't find the way to do it, should I use python console in QGIS or jus the command in my computer?

And what should I write to connect these two things?

0

Not sure about connecting your plugin to the Python Console but you could just incorporate your script inside your plugin so that it can be executed from the interface. For example, if you have a push button with the objectName pushButton, you could add the following to your plugin_name.py file:

def script():
    # your_code

self.dockwidget.pushButton.clicked.connect(script)

Reload the plugin (you could use the exeptionally useful Plugin Reloader plugin) and when you click the push button, it will try and run the script.

As you created a script from the Python Console, you could receive errors about modules which have not been defined. In which case, you will need to import these at the top of your .py file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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