summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2007-02-07 03:39:41 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2007-02-07 03:39:41 (GMT)
commitca30acfea89b7494b8e0d8d68fd613cb8a499eab (patch)
treee6ef23b52af926732d78808f0096778773a60d47
parentf30ff3b8fd79393f0b0a149b682c6a6bf5c2137a (diff)
downloadcpython-ca30acfea89b7494b8e0d8d68fd613cb8a499eab.zip
cpython-ca30acfea89b7494b8e0d8d68fd613cb8a499eab.tar.gz
cpython-ca30acfea89b7494b8e0d8d68fd613cb8a499eab.tar.bz2
[ 1621265 ] Auto-completion list placement
Move AC window below input line unless not enough space, then put it above. Patch: Tal Einat
-rw-r--r--Lib/idlelib/AutoCompleteWindow.py21
-rw-r--r--Lib/idlelib/NEWS.txt3
2 files changed, 18 insertions, 6 deletions
diff --git a/Lib/idlelib/AutoCompleteWindow.py b/Lib/idlelib/AutoCompleteWindow.py
index d02a695..05cd42a 100644
--- a/Lib/idlelib/AutoCompleteWindow.py
+++ b/Lib/idlelib/AutoCompleteWindow.py
@@ -215,13 +215,22 @@ class AutoCompleteWindow:
if not self.is_active():
return
# Position the completion list window
+ text = self.widget
+ text.see(self.startindex)
+ x, y, cx, cy = text.bbox(self.startindex)
acw = self.autocompletewindow
- self.widget.see(self.startindex)
- x, y, cx, cy = self.widget.bbox(self.startindex)
- acw.wm_geometry("+%d+%d" % (x + self.widget.winfo_rootx(),
- y + self.widget.winfo_rooty() \
- -acw.winfo_height()))
-
+ acw_width, acw_height = acw.winfo_width(), acw.winfo_height()
+ text_width, text_height = text.winfo_width(), text.winfo_height()
+ new_x = text.winfo_rootx() + min(x, max(0, text_width - acw_width))
+ new_y = text.winfo_rooty() + y
+ if (text_height - (y + cy) >= acw_height # enough height below
+ or y < acw_height): # not enough height above
+ # place acw below current line
+ new_y += cy
+ else:
+ # place acw above current line
+ new_y -= acw_height
+ acw.wm_geometry("+%d+%d" % (new_x, new_y))
def hide_event(self, event):
if not self.is_active():
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index ec6a5b1..52c7f00 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,9 @@ What's New in IDLE 2.6a1?
*Release date: XX-XXX-200X*
+- AutoCompleteWindow moved below input line, will move above if there
+ isn't enough space. Patch 1621265 Tal Einat
+
- Calltips now 'handle' tuples in the argument list (display '<tuple>' :)
Suggested solution by Christos Georgiou, Bug 791968.