49
One solution to giving adequate information is to supply a printed manual, another is to
provide a help system. There are several possible approaches that can be used to create a
suitable online help system; we will mention them all, and show one of them. We will return
to the Image Changer application introduced in Chapter 6, and in this chapter's first section
we will show the implementation of the application's MainWindow.helpHelp()
method, and how to provide an online help system.
Throughout the book, the applications shown have provided menu texts, button texts,
labels, tips, and so on, in English. This is fine for the minority of the world's people who
can read English, but not much use to those who speak the world's most widely spoken
language, Mandarin Chinese, or to those who speak other major languages such as Spanish,
Arabic, Hindi, Portuguese, Bengali, Russian, or Japanese.
To make an application as widely useable as possible it must be accessible to non-English
speakers. PyQt provides a toolchain for identifying user-visible strings and for making
these strings available in the easy-to-use Qt Linguist GUI application that human
translators can use to provide suitable translations. In this chapter's second section we will
discuss the translation tools and show how to use them. We will also present a new
translation-aware version of the Image Changer application suitable for use with the
translation tools.
Online Help
There are three common ways of providing an online help system. One approach is to
provide the help in the form of HTML files, and to launch a web browser set to the relevant
page. Another is to use the Qt Assistant application provided with Qt. And another to
provide a help form, again using HTML, but with the images and HTML files as resources.
The first approach can be achieved by launching a web browser as a separate process, either
using Python's subprocess module, or using PyQt's QProcess class. Qt 4.2 introduced
a new class, QDesktopServices, that makes it really easy to launch a browser in a
platform independent way with its openUrl() static convenience method.
The second approach is trickier since it requires us to create an XML file in a special format
and to distribute Qt Assistant with our application. The advantage of using Qt Assistant
is that it provides automatic indexing.
The third approach, using a custom help form and with HTML files and images as
resources, is the one that we will use. We saw back in Chapter 6 when we looked at resource
files, that we could include arbitrary files, including HTML files, and we incorporated some
demo help files in our resources.qrc file. Here is the code for the Image Changer's
MainWindow.helpHelp() method:
Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt Programming
Page 509
Return to Table
of
Contents
Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt Programming
Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt Programming
By Mark Summerfield ISBN: 9780132354189 Publisher: Prentice Hall
Prepared for Paul Waddell, Safari ID: pwaddell@u.washington.edu
Print Publication Date: 2007/10/19
User number: 905221 Copyright 2007, Safari Books Online, LLC.
This PDF is exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means without the prior
written permission for reprints and excerpts from the publisher. Redistribution or other use that violates the fair use priviledge under U.S. copyright laws (see 17 USC107) or that
otherwise violates the Safari Terms of Service is strictly prohibited.