Graphics Reference
In-Depth Information
def __init__(self, iface):
self.iface = iface
def initGui(self):
self.action = QAction("Run", self.iface.mainWindow())
QObject.connect(self.action, SIGNAL("triggered()"),
self.onRun)
self.iface.addPluginToMenu("Test Plugin", self.action)
def unload(self):
self.iface.removePluginMenu("Test Plugin", self.action)
def onRun(self):
QMessageBox.information(self.iface.mainWindow(),
"debug",
"Running")
As you can see, we created a Qt
QAction
object for our menu item, named it
Run
, and
added it to the
Plugin
menu in a submenu named "Test Plugin". We then connected that
action to our
onRun()
method, which simply displays a message to the user stating that
the plugin is running.
This is all we need for a very minimal plugin. Let's test it out. Start QGIS and choose the
Manage and Install Plugins…
item from the
Plugins
menu. The QGIS
Plugin Manager
window will appear, and if you scroll down, you should see your plugin listed: