diff options
author | Guido van Rossum <guido@python.org> | 1999-06-03 12:07:50 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-06-03 12:07:50 (GMT) |
commit | 23c115f1c9495f6899e8964c277442360d8fcf54 (patch) | |
tree | 8c375f80e8ce3d4092f8f760af5d214383c52046 /Tools/idle/CallTips.py | |
parent | ce900defc57eb8d38ad5da8416ff0ded08df34c3 (diff) | |
download | cpython-23c115f1c9495f6899e8964c277442360d8fcf54.zip cpython-23c115f1c9495f6899e8964c277442360d8fcf54.tar.gz cpython-23c115f1c9495f6899e8964c277442360d8fcf54.tar.bz2 |
Mark Hammond fixed some comments and improved the way the tip text is
constructed.
Diffstat (limited to 'Tools/idle/CallTips.py')
-rw-r--r-- | Tools/idle/CallTips.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Tools/idle/CallTips.py b/Tools/idle/CallTips.py index 33d1290..0bdeb92 100644 --- a/Tools/idle/CallTips.py +++ b/Tools/idle/CallTips.py @@ -1,3 +1,6 @@ +# CallTips.py - An IDLE extension that provides "Call Tips" - ie, a floating window that +# displays parameter information as you open parens. + import string import sys import types @@ -28,7 +31,9 @@ class CallTips: self._make_calltip_window = self.text.make_calltip_window else: self._make_calltip_window = self._make_tk_calltip_window - + + # Makes a Tk based calltip window. Used by IDLE, but not Pythonwin. + # See __init__ above for how this is used. def _make_tk_calltip_window(self): import CallTipWindow return CallTipWindow.CallTip(self.text) @@ -54,10 +59,6 @@ class CallTips: return "" #so the event is handled normally. def check_calltip_cancel_event(self, event): - # This doesnt quite work correctly as it is processed - # _before_ the key is handled. Thus, when the "Up" key - # is pressed, this test happens before the cursor is moved. - # This will do for now. if self.calltip: # If we have moved before the start of the calltip, # or off the calltip line, then cancel the tip. @@ -73,8 +74,8 @@ class CallTips: def get_object_at_cursor(self, wordchars="._" + string.uppercase + string.lowercase + string.digits): - # XXX - This need to be moved to a better place - # as the "." attribute lookup code can also use it. + # XXX - This needs to be moved to a better place + # so the "." attribute lookup code can also use it. text = self.text chars = text.get("insert linestart", "insert") i = len(chars) @@ -109,14 +110,14 @@ def get_arg_text(ob): defaults = ob.func_defaults or [] defaults = list(map(lambda name: "=%s" % name, defaults)) defaults = [""] * (len(realArgs)-len(defaults)) + defaults - argText = string.join( map(lambda arg, dflt: arg+dflt, realArgs, defaults), ", ") + items = map(lambda arg, dflt: arg+dflt, realArgs, defaults) if len(realArgs)+argOffset < (len(ob.func_code.co_varnames) - len(ob.func_code.co_names) ): - if argText: argText = argText + ", " - argText = argText + "..." + items.append("...") + argText = string.join(items , ", ") argText = "(%s)" % argText except: pass - # Can't build an argument list - see if we can use a docstring. + # See if we can use the docstring if hasattr(ob, "__doc__") and ob.__doc__: pos = string.find(ob.__doc__, "\n") if pos<0 or pos>70: pos=70 |