[ 1621265 ] Auto-completion list placement

Move AC window below input line unless not enough space, then put it above.
Patch: Tal Einat
This commit is contained in:
Kurt B. Kaiser 2007-02-07 03:39:41 +00:00
parent f30ff3b8fd
commit ca30acfea8
2 changed files with 18 additions and 6 deletions

View File

@ -215,13 +215,22 @@ class AutoCompleteWindow:
if not self.is_active(): if not self.is_active():
return return
# Position the completion list window # Position the completion list window
text = self.widget
text.see(self.startindex)
x, y, cx, cy = text.bbox(self.startindex)
acw = self.autocompletewindow acw = self.autocompletewindow
self.widget.see(self.startindex) acw_width, acw_height = acw.winfo_width(), acw.winfo_height()
x, y, cx, cy = self.widget.bbox(self.startindex) text_width, text_height = text.winfo_width(), text.winfo_height()
acw.wm_geometry("+%d+%d" % (x + self.widget.winfo_rootx(), new_x = text.winfo_rootx() + min(x, max(0, text_width - acw_width))
y + self.widget.winfo_rooty() \ new_y = text.winfo_rooty() + y
-acw.winfo_height())) 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): def hide_event(self, event):
if not self.is_active(): if not self.is_active():

View File

@ -3,6 +3,9 @@ What's New in IDLE 2.6a1?
*Release date: XX-XXX-200X* *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>' :) - Calltips now 'handle' tuples in the argument list (display '<tuple>' :)
Suggested solution by Christos Georgiou, Bug 791968. Suggested solution by Christos Georgiou, Bug 791968.