(self, event)
| 231 | return None |
| 232 | |
| 233 | def winconfig_event(self, event): |
| 234 | if self.is_configuring: |
| 235 | # Avoid running on recursive <Configure> callback invocations. |
| 236 | return |
| 237 | |
| 238 | self.is_configuring = True |
| 239 | if not self.is_active(): |
| 240 | return |
| 241 | |
| 242 | # Since the <Configure> event may occur after the completion window is gone, |
| 243 | # catch potential TclError exceptions when accessing acw. See: bpo-41611. |
| 244 | try: |
| 245 | # Position the completion list window |
| 246 | text = self.widget |
| 247 | text.see(self.startindex) |
| 248 | x, y, cx, cy = text.bbox(self.startindex) |
| 249 | acw = self.autocompletewindow |
| 250 | if platform.system().startswith('Windows'): |
| 251 | # On Windows an update() call is needed for the completion |
| 252 | # list window to be created, so that we can fetch its width |
| 253 | # and height. However, this is not needed on other platforms |
| 254 | # (tested on Ubuntu and macOS) but at one point began |
| 255 | # causing freezes on macOS. See issues 37849 and 41611. |
| 256 | acw.update() |
| 257 | acw_width, acw_height = acw.winfo_width(), acw.winfo_height() |
| 258 | text_width, text_height = text.winfo_width(), text.winfo_height() |
| 259 | new_x = text.winfo_rootx() + min(x, max(0, text_width - acw_width)) |
| 260 | new_y = text.winfo_rooty() + y |
| 261 | if (text_height - (y + cy) >= acw_height # enough height below |
| 262 | or y < acw_height): # not enough height above |
| 263 | # place acw below current line |
| 264 | new_y += cy |
| 265 | else: |
| 266 | # place acw above current line |
| 267 | new_y -= acw_height |
| 268 | acw.wm_geometry("+%d+%d" % (new_x, new_y)) |
| 269 | acw.deiconify() |
| 270 | acw.update_idletasks() |
| 271 | except TclError: |
| 272 | pass |
| 273 | |
| 274 | if platform.system().startswith('Windows'): |
| 275 | # See issue 15786. When on Windows platform, Tk will misbehave |
| 276 | # to call winconfig_event multiple times, we need to prevent this, |
| 277 | # otherwise mouse button double click will not be able to used. |
| 278 | try: |
| 279 | acw.unbind(WINCONFIG_SEQUENCE, self.winconfigid) |
| 280 | except TclError: |
| 281 | pass |
| 282 | self.winconfigid = None |
| 283 | |
| 284 | self.is_configuring = False |
| 285 | |
| 286 | def _hide_event_check(self): |
| 287 | if not self.autocompletewindow: |
nothing calls this directly
no test coverage detected