1010
1111# https://wiki.tcl-lang.org/page/Changing+Widget+Colors
1212
13+ import contextlib
1314import tkinter as tk
1415from platform import system as platform_system
1516from tkinter import messagebox , ttk
@@ -508,7 +509,8 @@ def __init__( # pylint: disable=too-many-arguments, too-many-positional-argumen
508509 def _cancel_show (self ) -> None :
509510 """Cancel any pending show timer."""
510511 if self .show_timer :
511- self .widget .after_cancel (self .show_timer )
512+ with contextlib .suppress (tk .TclError ):
513+ self .widget .after_cancel (self .show_timer )
512514 self .show_timer = None
513515
514516 def show (self , event : Optional [tk .Event ] = None ) -> None : # noqa: ARG002 # pylint: disable=unused-argument
@@ -523,13 +525,16 @@ def show(self, event: Optional[tk.Event] = None) -> None: # noqa: ARG002 # pyli
523525 def _cancel_hide (self , event : Optional [tk .Event ] = None ) -> None : # noqa: ARG002 # pylint: disable=unused-argument
524526 """Cancel the hide timer."""
525527 if self .hide_timer :
526- self .widget .after_cancel (self .hide_timer )
528+ with contextlib .suppress (tk .TclError ):
529+ self .widget .after_cancel (self .hide_timer )
527530 self .hide_timer = None
528531
529532 def _hide_active_tooltip (self ) -> None :
530533 """Hide another active tooltip before showing this one."""
531534 if Tooltip ._active_tooltip and Tooltip ._active_tooltip is not self :
532- Tooltip ._active_tooltip .force_hide ()
535+ with contextlib .suppress (tk .TclError ):
536+ Tooltip ._active_tooltip .force_hide ()
537+ Tooltip ._active_tooltip = None
533538
534539 def schedule_show (self , event : Optional [tk .Event ] = None ) -> None : # noqa: ARG002 # pylint: disable=unused-argument
535540 """Delay tooltip creation slightly to avoid flicker during pointer movement."""
@@ -568,6 +573,9 @@ def create_show(self, event: Optional[tk.Event] = None) -> None: # noqa: ARG002
568573 )
569574 tooltip_label .pack ()
570575 self .position_tooltip ()
576+
577+ self .tooltip .update_idletasks () # Force macOS to finish rendering text
578+
571579 self .tooltip .deiconify ()
572580 Tooltip ._active_tooltip = self
573581
0 commit comments