How to provide context sensative help.

Chuck Meyers chuck.meyers at lmco.com
Thu Aug 24 16:08:18 EDT 2000


I may not have been clear in my previous post ("Python vs. Tcl
Question...". I made the classic error of not explaining the "real
problem" and only asking a smaller question out of context.

I am designing a way to implement GUI help in python code. The goal is
to come as close as possible to a way of provide context sensitive help
in a GUI almost automatically without have write any code, just
maintaining an external help document. When the user pushes the
appropriate function key (or right mouse clicks, or <CTRL-h>, etc.) help
comes up specifically to the widget you had just entered.

I see how to do this in Tcl:

Bind a button click (or whatever) in all widgets to calling an external
script, passing that script the widgets name.

The external script would take the name and look up key words associated
with it or if you use the right naming conventions the widget name would
identify key words.

Once the key words are identified the script would scan a help document
or documents looking for those key words. Once found the section of the
help document specific to the widget is displayed to the user. If no key
words are found show the user the table of contents of the help
document.

The GUI programmer writes code without having to do anything special
(other than include a few lines of reusable code to bind all widgets to
some action). A help document would have to be maintained, and an
external script linking the help document to the code would have to be
written, but by using the right naming conventions for widgets you could
parse keywords from the widget name. The later would allow you to reuse
the same external script for all you applications.

I don't see how to do this in Python. event.widget doesn't give you the
unique widget name so you could not parse key words from the name. It
seems that the simplest Python solution is to bind entering the widget
to setting a list of key words for the widget. This list would constanly
be over written as you enter and exit widgets. You could then use the
list to pass key words to the external script that will then decide for
subject to display help.

The above works, but it is not as simple or clean as the Tcl solution.
Does anyone see a cleaner way to do this in Python?








More information about the Python-list mailing list