Build a help system for a Python application
martin.franklin at westgeo.com
Thu Jan 10 09:45:56 EST 2002
William Annis wrote:
> Martin Franklin <martin.franklin at westgeo.com> writes:
>> I use HTML for my help files and a little html viewer (based on the
>> Text widget I found inside the PTUI tool (check the vaults) This is OK
>> for basic help but does not support images.....
> Hmm. I did basically the same thing, ripping out certain
> dependencies, and moving some classes into the file so that the help
> system fit into a single .py. I also made some changes to how the
> fonts worked, so a little more HTML actually works. I use it in my
> Mom.v3 code.
> Perhaps we should compare notes, and make the thing public.
> Several people have asked for small, simple HTML viewer for on-line
> help. It might even be pretty simple to make images work.
Sounds good to me. I just had a look at the code and I do have a
showImage method in my htmlviewer class..... I think I recall finding this
'out there somewhere' and putting it into to my version.
def showImage(self, src, alt, ismap, align, width, height):
url=install_dir+'/'+src ### don't recall why I added this?!?
img = Tkinter.PhotoImage(file=url)
self.text.insert('insert', 'Image file error alt=%s\n' %alt)
self.text.insert('insert', '*** Broken Image ***\n')
img = None
padx, pady = 10, 10
padx, pady = 0, 20
if string.lower(align) == "left":
padx = 0
self.text.image_create(index="insert", image=img, padx=padx,
self.images.append(img) # keep a reference
You also require a the following method in the Parser class...
def handle_image(self, src, alt, ismap, align, width, height):
self.formatter.writer.viewer.showImage(src, alt, ismap, align,
More information about the Python-list