@@ -52,10 +52,12 @@ def __init__(self, widget):
5252 # (for example, he clicked the list)
5353 self .userwantswindow = None
5454 # event ids
55- self .hideid = self .keypressid = self .listupdateid = self . winconfigid \
56- = self .keyreleaseid = self .doubleclickid = None
55+ self .hideid = self .keypressid = self .listupdateid = \
56+ self . winconfigid = self .keyreleaseid = self .doubleclickid = None
5757 # Flag set if last keypress was a tab
5858 self .lastkey_was_tab = False
59+ # Flag set to avoid recursive <Configure> callback invocations.
60+ self .is_configuring = False
5961
6062 def _change_start (self , newstart ):
6163 min_len = min (len (self .start ), len (newstart ))
@@ -223,19 +225,26 @@ def show_window(self, comp_lists, index, complete, mode, userWantsWin):
223225 self .widget .event_add (KEYRELEASE_VIRTUAL_EVENT_NAME ,KEYRELEASE_SEQUENCE )
224226 self .listupdateid = listbox .bind (LISTUPDATE_SEQUENCE ,
225227 self .listselect_event )
228+ self .is_configuring = False
226229 self .winconfigid = acw .bind (WINCONFIG_SEQUENCE , self .winconfig_event )
227230 self .doubleclickid = listbox .bind (DOUBLECLICK_SEQUENCE ,
228231 self .doubleclick_event )
229232 return None
230233
231234 def winconfig_event (self , event ):
235+ if self .is_configuring :
236+ # Avoid running on recursive <Configure> callback invocations.
237+ return
238+
239+ self .is_configuring = True
232240 if not self .is_active ():
233241 return
234242 # Position the completion list window
235243 text = self .widget
236244 text .see (self .startindex )
237245 x , y , cx , cy = text .bbox (self .startindex )
238246 acw = self .autocompletewindow
247+ acw .update ()
239248 acw_width , acw_height = acw .winfo_width (), acw .winfo_height ()
240249 text_width , text_height = text .winfo_width (), text .winfo_height ()
241250 new_x = text .winfo_rootx () + min (x , max (0 , text_width - acw_width ))
@@ -256,6 +265,8 @@ def winconfig_event(self, event):
256265 acw .unbind (WINCONFIG_SEQUENCE , self .winconfigid )
257266 self .winconfigid = None
258267
268+ self .is_configuring = False
269+
259270 def _hide_event_check (self ):
260271 if not self .autocompletewindow :
261272 return
0 commit comments