[Qgis-developer] Displaying help files for a plugin
ccrook at linz.govt.nz
Mon Feb 8 12:54:04 EST 2010
Turns out QDesktopServices.openUrl doesn't quite work on Windows with a file:// type url - at least in the version of Qt we are using. But the good news is that it is already handled in Qgis. The QgsInterface class has an openURL methods (note captilisation) that does the job. It takes two parameters, a string (the url), and a boolean which if true causes it to look in the Qgis documentation folder. So the code I ended up with (based on Barry's) is
from os import path
file = inspect.getsourcefile(pluginClass)
file = 'file://' + path.splitext(file) + '.html'
file = file.replace("\\","/")
Thanks for the pointers Barry
From: qgis-developer-bounces at lists.osgeo.org [qgis-developer-bounces at lists.osgeo.org] On Behalf Of Barry Rowlingson [b.rowlingson at lancaster.ac.uk]
Sent: 06 February 2010 01:55
To: qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-developer] Displaying help files for a plugin
On Thu, Feb 4, 2010 at 9:54 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Is there a preferred way of displaying help information from a Python
> I'd like to display HTML help files located in the plugin directory. I'm
> wondering if there is a class for displaying this in the same way as the
> main quantum help information?
> Thanks in advance for any suggestions :-)
In the QDesktopServices class there's a openUrl method that should
use the user's preferred browser. You just have to construct a file:
URL to your documentation in a QUrl object. You can get the path to
your module's file from the __file__ member, but I did see recently
there's a python module that does that, but I can't remember what it's
I think that's what Qgis help does, I'd have to look at the source to be sure!
Ah, here's a snippet from a plugin wot I wrote. ArlatSettings is a
module in my plugin, and my help is all in the Documentation subdir:
(arlatDir,fname) = os.path.split(ArlatSettings.__file__)
docDir = os.path.join(arlatDir,"Documentation","index.html")
# convert \ to / in urls even for windows
docDir = docDir.replace("\\","/")
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org
This message contains information, which is confidential and may be subject to legal privilege.
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.
More information about the Qgis-developer