File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -431,10 +431,18 @@ def destroy(self, *args):
431
431
if self .canvas ._idle_callback :
432
432
self .canvas ._tkcanvas .after_cancel (self .canvas ._idle_callback )
433
433
434
- self .window .destroy ()
434
+ # NOTE: events need to be flushed before issuing destroy (GH #9956),
435
+ # however, self.window.update() can break user code. This is the
436
+ # safest way to achieve a complete draining of the event queue,
437
+ # but it may require users to update() on their own to execute the
438
+ # completion in obscure corner cases.
439
+ def delayed_destroy ():
440
+ self .window .destroy ()
441
+
442
+ if self ._owns_mainloop and not Gcf .get_num_fig_managers ():
443
+ self .window .quit ()
435
444
436
- if self ._owns_mainloop and not Gcf .get_num_fig_managers ():
437
- self .window .quit ()
445
+ self .window .after_idle (delayed_destroy )
438
446
439
447
def get_window_title (self ):
440
448
return self .window .wm_title ()
You can’t perform that action at this time.
0 commit comments