using pydoc in an application

T

timw.google

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.
 
T

timw.google

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,199
Messages
2,571,045
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top