[Qgis-developer] Plugin snippets & cookbook

Tim Sutton lists at linfiniti.com
Fri Mar 30 07:59:36 EDT 2012


Hi

On Fri, Mar 30, 2012 at 1:59 PM, Denis Rouzaud <denis.rouzaud at gmail.com> wrote:
> 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.
>

I'll take a look at why it is doing that.

Tim

>
> 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
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list