Checking sys.platform for substring 'win' was breaking IDLE docs on Mac
(darwin). Also, Mac Safari browser requires full file:// URIs. SF 900580 M EditorWindow.py M NEWS.txt M configHelpSourceEdit.py M idlever.py
This commit is contained in:
parent
69dc1c8f6a
commit
8aa23927e3
|
@ -60,11 +60,10 @@ class EditorWindow:
|
||||||
basepath = '/usr/share/doc/' # standard location
|
basepath = '/usr/share/doc/' # standard location
|
||||||
dochome = os.path.join(basepath, pyver,
|
dochome = os.path.join(basepath, pyver,
|
||||||
'Doc', 'index.html')
|
'Doc', 'index.html')
|
||||||
elif sys.platform.count('win') or sys.platform.count('nt'):
|
elif sys.platform[:3] == 'win':
|
||||||
chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2])
|
chmfile = os.path.join(sys.prefix, "Python%d%d.chm" % sys.version_info[:2])
|
||||||
if os.path.isfile(chmfile):
|
if os.path.isfile(chmfile):
|
||||||
dochome = chmfile
|
dochome = chmfile
|
||||||
print "dochome =", dochome
|
|
||||||
dochome = os.path.normpath(dochome)
|
dochome = os.path.normpath(dochome)
|
||||||
if os.path.isfile(dochome):
|
if os.path.isfile(dochome):
|
||||||
EditorWindow.help_url = dochome
|
EditorWindow.help_url = dochome
|
||||||
|
@ -314,20 +313,11 @@ class EditorWindow:
|
||||||
textView.TextViewer(self.top,'Help',fn)
|
textView.TextViewer(self.top,'Help',fn)
|
||||||
|
|
||||||
def python_docs(self, event=None):
|
def python_docs(self, event=None):
|
||||||
if sys.platform.count('win') or sys.platform.count('nt'):
|
if sys.platform[:3] == 'win':
|
||||||
os.startfile(self.help_url)
|
os.startfile(self.help_url)
|
||||||
return "break"
|
|
||||||
else:
|
else:
|
||||||
webbrowser.open(self.help_url)
|
webbrowser.open(self.help_url)
|
||||||
return "break"
|
return "break"
|
||||||
|
|
||||||
def display_docs(self, url):
|
|
||||||
if not (url.startswith('www') or url.startswith('http')):
|
|
||||||
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):
|
def cut(self,event):
|
||||||
self.text.event_generate("<<Cut>>")
|
self.text.event_generate("<<Cut>>")
|
||||||
|
@ -578,7 +568,12 @@ class EditorWindow:
|
||||||
def __extra_help_callback(self, helpfile):
|
def __extra_help_callback(self, helpfile):
|
||||||
"Create a callback with the helpfile value frozen at definition time"
|
"Create a callback with the helpfile value frozen at definition time"
|
||||||
def display_extra_help(helpfile=helpfile):
|
def display_extra_help(helpfile=helpfile):
|
||||||
self.display_docs(helpfile)
|
if not (helpfile.startswith('www') or helpfile.startswith('http')):
|
||||||
|
url = os.path.normpath(helpfile)
|
||||||
|
if sys.platform[:3] == 'win':
|
||||||
|
os.startfile(helpfile)
|
||||||
|
else:
|
||||||
|
webbrowser.open(helpfile)
|
||||||
return display_extra_help
|
return display_extra_help
|
||||||
|
|
||||||
def update_recent_files_list(self, new_file=None):
|
def update_recent_files_list(self, new_file=None):
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
What's New in IDLE 1.1a2?
|
||||||
|
=========================
|
||||||
|
|
||||||
|
*Release date: XX-JUL-2004*
|
||||||
|
|
||||||
|
- checking sys.platform for substring 'win' was breaking IDLE docs on Mac
|
||||||
|
(darwin). Also, Mac Safari browser requires full file:// URIs. SF 900580.
|
||||||
|
|
||||||
|
|
||||||
What's New in IDLE 1.1a1?
|
What's New in IDLE 1.1a1?
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"Dialog to specify or edit the parameters for a user configured help source."
|
"Dialog to specify or edit the parameters for a user configured help source."
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from Tkinter import *
|
from Tkinter import *
|
||||||
import tkMessageBox
|
import tkMessageBox
|
||||||
|
@ -84,7 +85,7 @@ class GetHelpSourceDialog(Toplevel):
|
||||||
dir, base = os.path.split(path)
|
dir, base = os.path.split(path)
|
||||||
else:
|
else:
|
||||||
base = None
|
base = None
|
||||||
if sys.platform.count('win') or sys.platform.count('nt'):
|
if sys.platform[:3] == 'win':
|
||||||
dir = os.path.join(os.path.dirname(sys.executable), 'Doc')
|
dir = os.path.join(os.path.dirname(sys.executable), 'Doc')
|
||||||
if not os.path.isdir(dir):
|
if not os.path.isdir(dir):
|
||||||
dir = os.getcwd()
|
dir = os.getcwd()
|
||||||
|
@ -127,19 +128,30 @@ class GetHelpSourceDialog(Toplevel):
|
||||||
self.entryPath.focus_set()
|
self.entryPath.focus_set()
|
||||||
pathOk = False
|
pathOk = False
|
||||||
elif path.startswith('www.') or path.startswith('http'):
|
elif path.startswith('www.') or path.startswith('http'):
|
||||||
pathOk = True
|
pass
|
||||||
elif not os.path.exists(path):
|
else:
|
||||||
tkMessageBox.showerror(title='File Path Error',
|
if path[:5] == 'file:':
|
||||||
message='Help file path does not exist.',
|
path = path[5:]
|
||||||
parent=self)
|
if not os.path.exists(path):
|
||||||
self.entryPath.focus_set()
|
tkMessageBox.showerror(title='File Path Error',
|
||||||
pathOk = False
|
message='Help file path does not exist.',
|
||||||
|
parent=self)
|
||||||
|
self.entryPath.focus_set()
|
||||||
|
pathOk = False
|
||||||
return pathOk
|
return pathOk
|
||||||
|
|
||||||
def Ok(self, event=None):
|
def Ok(self, event=None):
|
||||||
if self.MenuOk() and self.PathOk():
|
if self.MenuOk() and self.PathOk():
|
||||||
self.result = (self.menu.get().strip(),
|
self.result = (self.menu.get().strip(),
|
||||||
self.path.get().strip())
|
self.path.get().strip())
|
||||||
|
if sys.platform == 'darwin':
|
||||||
|
path = self.result[1]
|
||||||
|
if (path.startswith('www') or path.startswith('file:')
|
||||||
|
or path.startswith('http:')):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# Mac Safari insists on using the URI form for local files
|
||||||
|
self.result[1] = "file://" + path
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def Cancel(self, event=None):
|
def Cancel(self, event=None):
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
IDLE_VERSION = "1.1a0"
|
IDLE_VERSION = "1.1a2"
|
||||||
|
|
Loading…
Reference in New Issue