aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/idlelib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/FileList.py2
-rw-r--r--Lib/idlelib/MultiCall.py28
-rw-r--r--Lib/idlelib/PyShell.py2
-rw-r--r--Lib/idlelib/WidgetRedirector.py2
-rw-r--r--Lib/idlelib/idlever.py2
-rw-r--r--Lib/idlelib/macosxSupport.py49
6 files changed, 55 insertions, 30 deletions
diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py
index 9c6fafeaa4d..860dbaefda6 100644
--- a/Lib/idlelib/FileList.py
+++ b/Lib/idlelib/FileList.py
@@ -44,7 +44,7 @@ class FileList:
return self.EditorWindow(self, filename)
def close_all_callback(self, event):
- for edit in self.inversedict.keys():
+ for edit in list(self.inversedict):
reply = edit.close()
if reply == "cancel":
break
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py
index 4311999a2fa..f43f83e8934 100644
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/MultiCall.py
@@ -105,18 +105,32 @@ class _SimpleBinder:
# _state_subsets gives for each combination of modifiers, or *state*,
# a list of the states which are a subset of it. This list is ordered by the
# number of modifiers is the state - the most specific state comes first.
-# XXX rewrite without overusing functional primitives :-)
_states = range(1 << len(_modifiers))
_state_names = [''.join(m[0]+'-'
for i, m in enumerate(_modifiers)
if (1 << i) & s)
for s in _states]
-_state_subsets = map(lambda i: filter(lambda j: not (j & (~i)), _states),
- _states)
-for l in _state_subsets:
- l.sort(lambda a, b, nummod = lambda x: len(filter(lambda i: (1<<i) & x,
- range(len(_modifiers)))):
- nummod(b) - nummod(a))
+
+def expand_substates(states):
+ '''For each item of states return a list containing all combinations of
+ that item with individual bits reset, sorted by the number of set bits.
+ '''
+ def nbits(n):
+ "number of bits set in n base 2"
+ nb = 0
+ while n:
+ n, rem = divmod(n, 2)
+ nb += rem
+ return nb
+ statelist = []
+ for state in states:
+ substates = list(set(state & x for x in states))
+ substates.sort(lambda a,b: nbits(b) - nbits(a))
+ statelist.append(substates)
+ return statelist
+
+_state_subsets = expand_substates(_states)
+
# _state_codes gives for each state, the portable code to be passed as mc_state
_state_codes = []
for s in _states:
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 2d69157b1ae..f11e609d9ce 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -351,8 +351,6 @@ class ModifiedInterpreter(InteractiveInterpreter):
def build_subprocess_arglist(self):
w = ['-W' + s for s in sys.warnoptions]
- if 1/2 > 0: # account for new division
- w.append('-Qnew')
# Maybe IDLE is installed and is being accessed via sys.path,
# or maybe it's not installed and the idle.py script is being
# run from the IDLE source directory.
diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/WidgetRedirector.py
index 59005b8708c..459fea704c5 100644
--- a/Lib/idlelib/WidgetRedirector.py
+++ b/Lib/idlelib/WidgetRedirector.py
@@ -19,7 +19,7 @@ class WidgetRedirector:
self.widget._w)
def close(self):
- for name in self.dict.keys():
+ for name in list(self.dict.keys()):
self.unregister(name)
widget = self.widget; del self.widget
orig = self.orig; del self.orig
diff --git a/Lib/idlelib/idlever.py b/Lib/idlelib/idlever.py
index f56b4d4404b..636299d3f7a 100644
--- a/Lib/idlelib/idlever.py
+++ b/Lib/idlelib/idlever.py
@@ -1 +1 @@
-IDLE_VERSION = "2.6a0"
+IDLE_VERSION = "3.0x"
diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosxSupport.py
index ad61fff46f4..222abfce753 100644
--- a/Lib/idlelib/macosxSupport.py
+++ b/Lib/idlelib/macosxSupport.py
@@ -3,6 +3,7 @@ A number of function that enhance IDLE on MacOSX when it used as a normal
GUI application (as opposed to an X11 application).
"""
import sys
+import Tkinter
def runningAsOSXApp():
""" Returns True iff running from the IDLE.app bundle on OSX """
@@ -23,7 +24,11 @@ def addOpenEventSupport(root, flist):
root.createcommand("::tk::mac::OpenDocument", doOpenFile)
def hideTkConsole(root):
- root.tk.call('console', 'hide')
+ try:
+ root.tk.call('console', 'hide')
+ except Tkinter.TclError:
+ # Some versions of the Tk framework don't have a console object
+ pass
def overrideRootMenu(root, flist):
"""
@@ -75,32 +80,40 @@ def overrideRootMenu(root, flist):
import configDialog
configDialog.ConfigDialog(root, 'Settings')
+
root.bind('<<about-idle>>', about_dialog)
root.bind('<<open-config-dialog>>', config_dialog)
if flist:
root.bind('<<close-all-windows>>', flist.close_all_callback)
- for mname, entrylist in Bindings.menudefs:
- menu = menudict.get(mname)
- if not menu:
- continue
- for entry in entrylist:
- if not entry:
- menu.add_separator()
+
+ ###check if Tk version >= 8.4.14; if so, use hard-coded showprefs binding
+ tkversion = root.tk.eval('info patchlevel')
+ if tkversion >= '8.4.14':
+ Bindings.menudefs[0] = ('application', [
+ ('About IDLE', '<<about-idle>>'),
+ None,
+ ])
+ root.createcommand('::tk::mac::ShowPreferences', config_dialog)
+ else:
+ for mname, entrylist in Bindings.menudefs:
+ menu = menudict.get(mname)
+ if not menu:
+ continue
else:
- label, eventname = entry
- underline, label = prepstr(label)
- accelerator = get_accelerator(Bindings.default_keydefs,
+ for entry in entrylist:
+ if not entry:
+ menu.add_separator()
+ else:
+ label, eventname = entry
+ underline, label = prepstr(label)
+ accelerator = get_accelerator(Bindings.default_keydefs,
eventname)
- def command(text=root, eventname=eventname):
- text.event_generate(eventname)
- menu.add_command(label=label, underline=underline,
+ def command(text=root, eventname=eventname):
+ text.event_generate(eventname)
+ menu.add_command(label=label, underline=underline,
command=command, accelerator=accelerator)
-
-
-
-
def setupApp(root, flist):
"""
Perform setup for the OSX application bundle.