@@ -43,8 +43,26 @@ class EditorWindow:
4343 from MultiStatusBar import MultiStatusBar
4444
4545 vars = {}
46+ help_url = None
4647
4748 def __init__ (self , flist = None , filename = None , key = None , root = None ):
49+ if EditorWindow .help_url is None :
50+ if sys .platform .count ('linux' ):
51+ # look for html docs in a couple of standard places
52+ pyver = 'python-docs-' + '%s.%s.%s' % sys .version_info [:3 ]
53+ if os .path .isdir ('/var/www/html/python/' ): # "python2" rpm
54+ dochome = '/var/www/html/python/index.html'
55+ else :
56+ basepath = '/usr/share/doc/' # standard location
57+ dochome = os .path .join (basepath , pyver ,
58+ 'Doc' , 'index.html' )
59+ else :
60+ dochome = os .path .join (sys .prefix , 'Doc' , 'index.html' )
61+ dochome = os .path .normpath (dochome )
62+ if os .path .isfile (dochome ):
63+ EditorWindow .help_url = dochome
64+ else :
65+ EditorWindow .help_url = "http://www.python.org/doc/current"
4866 currentTheme = idleConf .CurrentTheme ()
4967 self .flist = flist
5068 root = root or flist .root
@@ -285,28 +303,20 @@ def help_dialog(self, event=None):
285303 fn = os .path .join (os .path .abspath (os .path .dirname (__file__ )),'help.txt' )
286304 textView .TextViewer (self .top ,'Help' ,fn )
287305
288- help_url = "http://www.python.org/doc/current/"
289- if sys .platform [:3 ] == "win" :
290- fn = os .path .dirname (__file__ )
291- fn = os .path .join (fn , os .pardir , os .pardir , "pythlp.chm" )
292- fn = os .path .normpath (fn )
293- if os .path .isfile (fn ):
294- help_url = fn
295- else :
296- fn = os .path .dirname (__file__ )
297- fn = os .path .join (fn , os .pardir , os .pardir , "Doc" , "index.html" )
298- fn = os .path .normpath (fn )
299- if os .path .isfile (fn ):
300- help_url = fn
301- del fn
302- def python_docs (self , event = None ):
306+ def python_docs (self , event = None ):
307+ if sys .platform .count ('win' ) or sys .platform .count ('nt' ):
303308 os .startfile (self .help_url )
304- else :
305- def python_docs (self , event = None ):
306- self .display_docs (self .help_url )
309+ return "break"
310+ else :
311+ webbrowser .open (self .help_url )
312+ return "break"
307313
308314 def display_docs (self , url ):
309- webbrowser .open (url )
315+ url = os .path .normpath (url )
316+ if sys .platform .count ('win' ) or sys .platform .count ('nt' ):
317+ os .startfile (url )
318+ else :
319+ webbrowser .open (url )
310320
311321 def cut (self ,event ):
312322 self .text .event_generate ("<<Cut>>" )
0 commit comments