[Python-checkins] r53653 - python/trunk/Lib/idlelib/AutoCompleteWindow.py python/trunk/Lib/idlelib/NEWS.txt

kurt.kaiser python-checkins at python.org
Wed Feb 7 04:39:42 CET 2007


Author: kurt.kaiser
Date: Wed Feb  7 04:39:41 2007
New Revision: 53653

Modified:
   python/trunk/Lib/idlelib/AutoCompleteWindow.py
   python/trunk/Lib/idlelib/NEWS.txt
Log:
[ 1621265 ] Auto-completion list placement
Move AC window below input line unless not enough space, then put it above.
Patch: Tal Einat


Modified: python/trunk/Lib/idlelib/AutoCompleteWindow.py
==============================================================================
--- python/trunk/Lib/idlelib/AutoCompleteWindow.py	(original)
+++ python/trunk/Lib/idlelib/AutoCompleteWindow.py	Wed Feb  7 04:39:41 2007
@@ -215,13 +215,22 @@
         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():

Modified: python/trunk/Lib/idlelib/NEWS.txt
==============================================================================
--- python/trunk/Lib/idlelib/NEWS.txt	(original)
+++ python/trunk/Lib/idlelib/NEWS.txt	Wed Feb  7 04:39:41 2007
@@ -3,6 +3,9 @@
 
 *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.
 


More information about the Python-checkins mailing list