[Qgis-developer] Displaying help files for a plugin
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Fri Feb 5 07:55:18 EST 2010
On Thu, Feb 4, 2010 at 9:54 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi
>
> Is there a preferred way of displaying help information from a Python
> plugin.
>
> 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
called now...
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:
import ArlatSettings
[more stuff]
def runHelp(self):
(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("\\","/")
QDesktopServices.openUrl(QUrl(docDir))
Barry
More information about the Qgis-developer
mailing list