summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/CallTips.py15
-rw-r--r--Lib/idlelib/Debugger.py3
-rw-r--r--Lib/idlelib/Icons/idle.icobin0 -> 19790 bytes
-rw-r--r--Lib/idlelib/Icons/idle_16.gifbin0 -> 1034 bytes
-rw-r--r--Lib/idlelib/Icons/idle_16.pngbin0 -> 1264 bytes
-rw-r--r--Lib/idlelib/Icons/idle_32.gifbin0 -> 1435 bytes
-rw-r--r--Lib/idlelib/Icons/idle_32.pngbin0 -> 2542 bytes
-rw-r--r--Lib/idlelib/Icons/idle_48.gifbin0 -> 1388 bytes
-rw-r--r--Lib/idlelib/Icons/idle_48.pngbin0 -> 4710 bytes
-rw-r--r--Lib/idlelib/Icons/python.gifbin125 -> 585 bytes
-rwxr-xr-xLib/idlelib/PyShell.py14
-rw-r--r--Lib/idlelib/SearchEngine.py8
-rw-r--r--Lib/idlelib/configDialog.py9
-rw-r--r--Lib/idlelib/idle_test/test_calltips.py42
14 files changed, 65 insertions, 26 deletions
diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/CallTips.py
index 4f88da6..81bd5f1 100644
--- a/Lib/idlelib/CallTips.py
+++ b/Lib/idlelib/CallTips.py
@@ -5,16 +5,16 @@ parameter and docstring information when you type an opening parenthesis, and
which disappear when you type a closing parenthesis.
"""
+import __main__
+import inspect
import re
import sys
+import textwrap
import types
-import inspect
from idlelib import CallTipWindow
from idlelib.HyperParser import HyperParser
-import __main__
-
class CallTips:
menudefs = [
@@ -117,8 +117,9 @@ def get_entity(expression):
return None
# The following are used in get_argspec and some in tests
-_MAX_COLS = 79
+_MAX_COLS = 85
_MAX_LINES = 5 # enough for bytes
+_INDENT = ' '*4 # for wrapped signatures
_first_param = re.compile('(?<=\()\w*\,?\s*')
_default_callable_argspec = "See source or doc"
@@ -149,13 +150,15 @@ def get_argspec(ob):
isinstance(ob_call, types.MethodType)):
argspec = _first_param.sub("", argspec)
+ lines = (textwrap.wrap(argspec, _MAX_COLS, subsequent_indent=_INDENT)
+ if len(argspec) > _MAX_COLS else [argspec] if argspec else [])
+
if isinstance(ob_call, types.MethodType):
doc = ob_call.__doc__
else:
doc = getattr(ob, "__doc__", "")
if doc:
- lines = [argspec] if argspec else []
- for line in doc.split('\n', 5)[:_MAX_LINES]:
+ for line in doc.split('\n', _MAX_LINES)[:_MAX_LINES]:
line = line.strip()
if not line:
break
diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py
index ed66084..d4872ed 100644
--- a/Lib/idlelib/Debugger.py
+++ b/Lib/idlelib/Debugger.py
@@ -254,8 +254,7 @@ class Debugger:
self.sync_source_line()
def show_frame(self, stackitem):
- frame, lineno = stackitem
- self.frame = frame
+ self.frame = stackitem[0] # lineno is stackitem[1]
self.show_variables()
localsviewer = None
diff --git a/Lib/idlelib/Icons/idle.ico b/Lib/idlelib/Icons/idle.ico
new file mode 100644
index 0000000..3357aef
--- /dev/null
+++ b/Lib/idlelib/Icons/idle.ico
Binary files differ
diff --git a/Lib/idlelib/Icons/idle_16.gif b/Lib/idlelib/Icons/idle_16.gif
new file mode 100644
index 0000000..9f001b1
--- /dev/null
+++ b/Lib/idlelib/Icons/idle_16.gif
Binary files differ
diff --git a/Lib/idlelib/Icons/idle_16.png b/Lib/idlelib/Icons/idle_16.png
new file mode 100644
index 0000000..6abde0a
--- /dev/null
+++ b/Lib/idlelib/Icons/idle_16.png
Binary files differ
diff --git a/Lib/idlelib/Icons/idle_32.gif b/Lib/idlelib/Icons/idle_32.gif
new file mode 100644
index 0000000..af5b2d5
--- /dev/null
+++ b/Lib/idlelib/Icons/idle_32.gif
Binary files differ
diff --git a/Lib/idlelib/Icons/idle_32.png b/Lib/idlelib/Icons/idle_32.png
new file mode 100644
index 0000000..41b70db
--- /dev/null
+++ b/Lib/idlelib/Icons/idle_32.png
Binary files differ
diff --git a/Lib/idlelib/Icons/idle_48.gif b/Lib/idlelib/Icons/idle_48.gif
new file mode 100644
index 0000000..fc5304f
--- /dev/null
+++ b/Lib/idlelib/Icons/idle_48.gif
Binary files differ
diff --git a/Lib/idlelib/Icons/idle_48.png b/Lib/idlelib/Icons/idle_48.png
new file mode 100644
index 0000000..e5fa928
--- /dev/null
+++ b/Lib/idlelib/Icons/idle_48.png
Binary files differ
diff --git a/Lib/idlelib/Icons/python.gif b/Lib/idlelib/Icons/python.gif
index 58271ed..b189c2c 100644
--- a/Lib/idlelib/Icons/python.gif
+++ b/Lib/idlelib/Icons/python.gif
Binary files differ
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 55fd357..2e5ebb2 100755
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -16,7 +16,7 @@ import io
import linecache
from code import InteractiveInterpreter
-from platform import python_version
+from platform import python_version, system
try:
from tkinter import *
@@ -1524,6 +1524,18 @@ def main():
# start editor and/or shell windows:
root = Tk(className="Idle")
+ # set application icon
+ icondir = os.path.join(os.path.dirname(__file__), 'Icons')
+ if system() == 'Windows':
+ iconfile = os.path.join(icondir, 'idle.ico')
+ root.wm_iconbitmap(default=iconfile)
+ elif TkVersion >= 8.5:
+ ext = '.png' if TkVersion >= 8.6 else '.gif'
+ iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext))
+ for size in (16, 32, 48)]
+ icons = [PhotoImage(file=iconfile) for iconfile in iconfiles]
+ root.wm_iconphoto(True, *icons)
+
fixwordbreaks(root)
root.withdraw()
flist = PyShellFileList(root)
diff --git a/Lib/idlelib/SearchEngine.py b/Lib/idlelib/SearchEngine.py
index bbd221d..9d3c4cb 100644
--- a/Lib/idlelib/SearchEngine.py
+++ b/Lib/idlelib/SearchEngine.py
@@ -83,11 +83,9 @@ class SearchEngine:
try:
prog = re.compile(pat, flags)
except re.error as what:
- try:
- msg, col = what
- except:
- msg = str(what)
- col = -1
+ args = what.args
+ msg = args[0]
+ col = arg[1] if len(args) >= 2 else -1
self.report_error(pat, msg, col)
return None
return prog
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 1f4a3a5..efe5c43 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -82,9 +82,10 @@ class ConfigDialog(Toplevel):
else:
extraKwds=dict(padx=6, pady=3)
- self.buttonHelp = Button(frameActionButtons,text='Help',
- command=self.Help,takefocus=FALSE,
- **extraKwds)
+# Comment out button creation and packing until implement self.Help
+## self.buttonHelp = Button(frameActionButtons,text='Help',
+## command=self.Help,takefocus=FALSE,
+## **extraKwds)
self.buttonOk = Button(frameActionButtons,text='Ok',
command=self.Ok,takefocus=FALSE,
**extraKwds)
@@ -98,7 +99,7 @@ class ConfigDialog(Toplevel):
self.CreatePageHighlight()
self.CreatePageKeys()
self.CreatePageGeneral()
- self.buttonHelp.pack(side=RIGHT,padx=5)
+## self.buttonHelp.pack(side=RIGHT,padx=5)
self.buttonOk.pack(side=LEFT,padx=5)
self.buttonApply.pack(side=LEFT,padx=5)
self.buttonCancel.pack(side=LEFT,padx=5)
diff --git a/Lib/idlelib/idle_test/test_calltips.py b/Lib/idlelib/idle_test/test_calltips.py
index eca24ec..f363764 100644
--- a/Lib/idlelib/idle_test/test_calltips.py
+++ b/Lib/idlelib/idle_test/test_calltips.py
@@ -1,5 +1,6 @@
import unittest
import idlelib.CallTips as ct
+import textwrap
import types
default_tip = ct._default_callable_argspec
@@ -64,20 +65,35 @@ class Get_signatureTest(unittest.TestCase):
gtest(types.MethodType, "method(function, instance)")
gtest(SB(), default_tip)
+ def test_signature_wrap(self):
+ self.assertEqual(signature(textwrap.TextWrapper), '''\
+(width=70, initial_indent='', subsequent_indent='', expand_tabs=True,
+ replace_whitespace=True, fix_sentence_endings=False, break_long_words=True,
+ drop_whitespace=True, break_on_hyphens=True, tabsize=8)''')
+
+ def test_docline_truncation(self):
+ def f(): pass
+ f.__doc__ = 'a'*300
+ self.assertEqual(signature(f), '()\n' + 'a' * (ct._MAX_COLS-3) + '...')
+
def test_multiline_docstring(self):
# Test fewer lines than max.
self.assertEqual(signature(list),
"list() -> new empty list\n"
"list(iterable) -> new list initialized from iterable's items")
- # Test max lines and line (currently) too long.
- self.assertEqual(signature(bytes),
-"bytes(iterable_of_ints) -> bytes\n"
-"bytes(string, encoding[, errors]) -> bytes\n"
-"bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer\n"
-#bytes(int) -> bytes object of size given by the parameter initialized with null bytes
-"bytes(int) -> bytes object of size given by the parameter initialized with n...\n"
-"bytes() -> empty bytes object")
+ # Test max lines
+ self.assertEqual(signature(bytes), '''\
+bytes(iterable_of_ints) -> bytes
+bytes(string, encoding[, errors]) -> bytes
+bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
+bytes(int) -> bytes object of size given by the parameter initialized with null bytes
+bytes() -> empty bytes object''')
+
+ # Test more than max lines
+ def f(): pass
+ f.__doc__ = 'a\n' * 15
+ self.assertEqual(signature(f), '()' + '\na' * ct._MAX_LINES)
def test_functions(self):
def t1(): 'doc'
@@ -106,6 +122,16 @@ class Get_signatureTest(unittest.TestCase):
(tc.__call__, '(ci)'), (tc, '(ci)'), (TC.cm, "(a)"),):
self.assertEqual(signature(meth), mtip + "\ndoc")
+ def test_starred_parameter(self):
+ # test that starred first parameter is *not* removed from argspec
+ class C:
+ def m1(*args): pass
+ def m2(**kwds): pass
+ c = C()
+ for meth, mtip in ((C.m1, '(*args)'), (c.m1, "(*args)"),
+ (C.m2, "(**kwds)"), (c.m2, "(**kwds)"),):
+ self.assertEqual(signature(meth), mtip)
+
def test_non_ascii_name(self):
# test that re works to delete a first parameter name that
# includes non-ascii chars, such as various forms of A.