summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/EditorWindow.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-01-10 05:07:24 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2003-01-10 05:07:24 (GMT)
commit114713d19451e893dc7dabea9b96d396baf7ecaf (patch)
tree8d4f8d2d478ea01856a70b957ab61739122393b3 /Lib/idlelib/EditorWindow.py
parent37f398282bf74b11e6167f7c7af75960e553dab9 (diff)
downloadcpython-114713d19451e893dc7dabea9b96d396baf7ecaf.zip
cpython-114713d19451e893dc7dabea9b96d396baf7ecaf.tar.gz
cpython-114713d19451e893dc7dabea9b96d396baf7ecaf.tar.bz2
1. Make finding Python help docs more robust, including the installed
configuation. 2. Make sure that os.startfile() is used to open both Python help docs and Extra Help docs on the Windows platforms.
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r--Lib/idlelib/EditorWindow.py48
1 files changed, 29 insertions, 19 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index 47256dc..af60eca 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -43,8 +43,26 @@ class EditorWindow:
from MultiStatusBar import MultiStatusBar
vars = {}
+ help_url = None
def __init__(self, flist=None, filename=None, key=None, root=None):
+ if EditorWindow.help_url is None:
+ if sys.platform.count('linux'):
+ # look for html docs in a couple of standard places
+ pyver = 'python-docs-' + '%s.%s.%s' % sys.version_info[:3]
+ if os.path.isdir('/var/www/html/python/'): # "python2" rpm
+ dochome = '/var/www/html/python/index.html'
+ else:
+ basepath = '/usr/share/doc/' # standard location
+ dochome = os.path.join(basepath, pyver,
+ 'Doc', 'index.html')
+ else:
+ dochome = os.path.join(sys.prefix, 'Doc', 'index.html')
+ dochome = os.path.normpath(dochome)
+ if os.path.isfile(dochome):
+ EditorWindow.help_url = dochome
+ else:
+ EditorWindow.help_url = "http://www.python.org/doc/current"
currentTheme=idleConf.CurrentTheme()
self.flist = flist
root = root or flist.root
@@ -285,28 +303,20 @@ class EditorWindow:
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
textView.TextViewer(self.top,'Help',fn)
- help_url = "http://www.python.org/doc/current/"
- if sys.platform[:3] == "win":
- fn = os.path.dirname(__file__)
- fn = os.path.join(fn, os.pardir, os.pardir, "pythlp.chm")
- fn = os.path.normpath(fn)
- if os.path.isfile(fn):
- help_url = fn
- else:
- fn = os.path.dirname(__file__)
- fn = os.path.join(fn, os.pardir, os.pardir, "Doc", "index.html")
- fn = os.path.normpath(fn)
- if os.path.isfile(fn):
- help_url = fn
- del fn
- def python_docs(self, event=None):
+ def python_docs(self, event=None):
+ if sys.platform.count('win') or sys.platform.count('nt'):
os.startfile(self.help_url)
- else:
- def python_docs(self, event=None):
- self.display_docs(self.help_url)
+ return "break"
+ else:
+ webbrowser.open(self.help_url)
+ return "break"
def display_docs(self, url):
- webbrowser.open(url)
+ url = os.path.normpath(url)
+ if sys.platform.count('win') or sys.platform.count('nt'):
+ os.startfile(url)
+ else:
+ webbrowser.open(url)
def cut(self,event):
self.text.event_generate("<<Cut>>")