Help, *.CHM, etc

Markus Wankus markus_wankus at hotmail.com
Wed Jan 21 11:42:56 EST 2004


If you are interested, here is a snippet of how I did it a long time ago 
in a galaxy far, far away.  It avoids spawning multiple instances of the 
same .chm.

# 
----------------------------------------------------------------------------
# The Help..Contents menu command
     def OnMnuHelpContents(self, event):
         """This method opens the Help file (if it isn't open already)."""
         # Display the help file - nothing fancy - just run it
         # ToDo - if already running bring to top (I can't see a way to do
         # this, currently)
         global helpfile_active

         helpfilename = os.path.join(r'path_to_your_helpfile', 
r'yourhelpfile.chm')
         if not helpfile_active:
             helpprocid = wxNewId()
             self.helpfile_process = wxProcess(self, helpprocid)
             EVT_END_PROCESS(self, helpprocid, self.OnHelpWindowTerminate)
             helpfile_active = wxExecute('hh.exe %s' % helpfilename, False,
                                     self.helpfile_process)
# 
----------------------------------------------------------------------------
     def OnHelpWindowTerminate(self, event):
         """This event function is fired when the help window is closed."""
         global helpfile_active

         if helpfile_active:
             self.helpfile_process.Detach()
             self.helpfile_process.Destroy()
         helpfile_active = 0
# 
----------------------------------------------------------------------------

Couldn't tell you if os.startfile is better or not...but I imagine 
wxExecute is calling the Windows ShellExecute under the covers anyway.  Of 
course, this also fails if they do not have hh.exe installed but this is 
only on stock Win95 or older NT machines with IE < 5.0.  I imagine you 
could spruce it up with more error checking.

You may also want to get rid of the global and use a real attribute...this 
is from my beginner days. ;o)

Markus.

On 20 Jan 2004 18:03:36 -0800, Tom <its1louder at yahoo.com> wrote:

> A question for gui application programmers. . .
> I 've got some GUI programs, written in Python/wxPython, and I've got
> a help button and a help menu item.  Also, I've got a compiled file
> made with the microsoft HTML workshop utility, lets call it
> c:\path\help.chm.  My question is how do you launch it from the GUI?
> What logic do I put behind the "help" button, in other words.
>
> I thought it would be
>
> os.spawnv(os.P_DETACH, "c:\\path\\help.chm", [])
>
> but I get an error:
>
> OSError: [Errno 8]  Exec format error
>
> so I guess help.chm isn't executable itself, but is associated with
> some unknown executable.  I tried explorer.exe- at the dos cmd line it
> basically works to type
>
> explorer.exe c:\path\help.chm
>
> although there is a nag screen that would be nice to do without.
>
> so you'd think
>
> os.spawnv(os.P_DETACH, 'explorer.exe', ["c:\\path\\help.chm"])
>
> would be equivalent but it fails.  I have to believe someone out there
> in python community likes to include help.chm with their applications,
> nad there is a right way to do this.
>
> On another note, are there pure python based help viewers that people
> use instead?  The reason I ask is that would be more portable then the
> *.chm files are.  If there is such a beast I can't find it.



More information about the Python-list mailing list