[Qgis-developer] Plugin snippets & cookbook

Denis Rouzaud denis.rouzaud at gmail.com
Fri Mar 30 07:59:00 EDT 2012


Hi Larry,

Thanks for the tips. I corrected snippet #11.

I did not see before I had uploaded it 3 times (sic).
But how can I delete the other two???

http://snippets.qgis.org/snippets/users/3nids/ leads to a 404.
dunno why.

On 03/30/2012 01:52 PM, Larry Shaffer wrote:
> Hi Denis,
>
> On Fri, Mar 30, 2012 at 3:57 AM, Denis Rouzaud<denis.rouzaud at gmail.com>  wrote:
>> ...
>> First, I propose to add these three lines in the code snippets. It is to
>> include help link in thew plugin menu:
>> def initGui(self):
>>   # This initiates the action
>>   self.helpAction = QAction(QIcon(":/plugins/myplugin/icons/help.png"),
>> "Help", self.iface.mainWindow())
>>   # This will open the website url using user's defined browser
>>   QObject.connect(self.helpAction, SIGNAL("triggered()"), lambda:
>> QDesktopServices.openUrl(QUrl("http://my.help.site/formyplugin")))
>>   # This will add the help link in the plugin menu, under the entry "My
>> Plugin"
>>   self.iface.addPluginToMenu("&My plugin", self.helpAction)
>> ...
> Nifty snippet.
>
> For connecting your signal to the lambda slot, how about new style instead?
>
> self.helpAction.triggered.connect(
>      lambda: QDesktopServices.openUrl(QUrl("http://my.help.site/formyplugin")))
>
> Also, you may want to note adding the removal call to the 'def
> unload(self)' method as well:
>
> self.iface.removePluginMenu("&My plugin", self.helpAction)
>
>
> btw: Your snippet seems to be appearing 3 times in the listing. Maybe
> a glitch with the site?
>
>
> Regards,
>
> Larry Shaffer
> Dakota Cartography
> Black Hills, South Dakota


More information about the Qgis-developer mailing list