using pydoc in an application

timw.google timothy.williams at nvl.army.mil
Tue Jun 27 14:10:14 EDT 2006


I went and looked at the pydoc.py code, and it looks like it isn't
really meant to be used from inside another python program. After some
tinkering arond with my code, I ended up with this: (Google is messing
up my indentation)

(in my __init__ function)
...

        menuBar.addmenuitem('Help', 'command', '',
                                               command=self.run_pydoc,
                                               label='Run pydoc (module
help GUI)')

...

    def run_pydoc(self):
        """Run pydoc -g for gui based help"""
        if 'linux' in sys.platform:
            os.system('pydoc -g')
        if 'win32' in sys.platform:
            os.system(os.path.join(sys.prefix,
                                   'Tools', 'Scripts',
                                   'pydocgui.pyw'))
        return

A bit of a kludge, but it works for me.

timw.google wrote:
> Hi all,
>
> I'm discovering pydoc, and it seems to me that this is a great way to
> have online documentation for my application. Are there any examples of
> using this in some kind of help menu in an application?  I've tried to
> just bind pydoc.gui() to a menu item, but this just brings up the GUI
> for pydoc, and the user still needs to search for the module before the
> browser comes up, and when I quit serving pydoc.gui(), my application
> dies along with it. Also, I need to get out of python to use pydoc.gui
> again, or I get
>
> error: (98, 'Address already in use')
>
> I'm sure there's a better way to take advantage of this module and my
> docstrings to get some online help.  I'm using Tkinter and Pmw, but
> maybe it's time to convert all this to wxWidgets?
> 
> Thanks for any help.




More information about the Python-list mailing list