@@ -52,10 +52,12 @@ def __init__(self, widget):
52
52
# (for example, he clicked the list)
53
53
self .userwantswindow = None
54
54
# 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
57
57
# Flag set if last keypress was a tab
58
58
self .lastkey_was_tab = False
59
+ # Flag set to avoid recursive <Configure> callback invocations.
60
+ self .is_configuring = False
59
61
60
62
def _change_start (self , newstart ):
61
63
min_len = min (len (self .start ), len (newstart ))
@@ -223,19 +225,26 @@ def show_window(self, comp_lists, index, complete, mode, userWantsWin):
223
225
self .widget .event_add (KEYRELEASE_VIRTUAL_EVENT_NAME ,KEYRELEASE_SEQUENCE )
224
226
self .listupdateid = listbox .bind (LISTUPDATE_SEQUENCE ,
225
227
self .listselect_event )
228
+ self .is_configuring = False
226
229
self .winconfigid = acw .bind (WINCONFIG_SEQUENCE , self .winconfig_event )
227
230
self .doubleclickid = listbox .bind (DOUBLECLICK_SEQUENCE ,
228
231
self .doubleclick_event )
229
232
return None
230
233
231
234
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
232
240
if not self .is_active ():
233
241
return
234
242
# Position the completion list window
235
243
text = self .widget
236
244
text .see (self .startindex )
237
245
x , y , cx , cy = text .bbox (self .startindex )
238
246
acw = self .autocompletewindow
247
+ acw .update ()
239
248
acw_width , acw_height = acw .winfo_width (), acw .winfo_height ()
240
249
text_width , text_height = text .winfo_width (), text .winfo_height ()
241
250
new_x = text .winfo_rootx () + min (x , max (0 , text_width - acw_width ))
@@ -256,6 +265,8 @@ def winconfig_event(self, event):
256
265
acw .unbind (WINCONFIG_SEQUENCE , self .winconfigid )
257
266
self .winconfigid = None
258
267
268
+ self .is_configuring = False
269
+
259
270
def _hide_event_check (self ):
260
271
if not self .autocompletewindow :
261
272
return
0 commit comments