@@ -477,33 +477,13 @@ def __init__( # pylint: disable=too-many-arguments, too-many-positional-argumen
477477 self .timers : dict [str , Optional [str ]] = {}
478478
479479 # Bind the <Enter> and <Leave> events to show and hide the tooltip
480- if platform_system () == "Darwin" :
481- # On macOS, defer tooltip creation slightly to avoid flashing while
482- # moving through dense tables and controls.
483- if tag_name and isinstance (self .widget , tk .Text ):
484- self .widget .tag_bind (tag_name , "<Enter>" , self .schedule_show , "+" )
485- self .widget .tag_bind (tag_name , "<Leave>" , self .destroy_hide , "+" )
486- else :
487- self .widget .bind ("<Enter>" , self .schedule_show , "+" )
488- self .widget .bind ("<Leave>" , self .destroy_hide , "+" )
480+ # Defer tooltip creation slightly to avoid flashing while moving through dense tables.
481+ if tag_name and isinstance (self .widget , tk .Text ):
482+ self .widget .tag_bind (tag_name , "<Enter>" , self .schedule_show , "+" )
483+ self .widget .tag_bind (tag_name , "<Leave>" , self .destroy_hide , "+" )
489484 else :
490- if tag_name and isinstance (self .widget , tk .Text ):
491- self .widget .tag_bind (tag_name , "<Enter>" , self .show , "+" )
492- self .widget .tag_bind (tag_name , "<Leave>" , self .hide , "+" )
493- else :
494- self .widget .bind ("<Enter>" , self .show , "+" )
495- self .widget .bind ("<Leave>" , self .hide , "+" )
496- # On non-macOS, create the tooltip immediately and show/hide it on events
497- self .tooltip = cast ("tk.Toplevel" , self .toplevel_class (widget ))
498- self .tooltip .wm_overrideredirect (boolean = True )
499- tooltip_label = ttk .Label (
500- self .tooltip , text = text , background = "#ffffe0" , relief = "solid" , borderwidth = 1 , justify = tk .LEFT
501- )
502- tooltip_label .pack ()
503- self .tooltip .withdraw () # Initially hide the tooltip
504- # Bind to tooltip to prevent hiding when mouse is over it
505- self .tooltip .bind ("<Enter>" , self ._cancel_hide )
506- self .tooltip .bind ("<Leave>" , self .hide )
485+ self .widget .bind ("<Enter>" , self .schedule_show , "+" )
486+ self .widget .bind ("<Leave>" , self .destroy_hide , "+" )
507487
508488 self .widget .bind ("<Destroy>" , self ._on_widget_destroy , "+" )
509489
@@ -517,14 +497,14 @@ def _cancel_timer(self, name: str) -> None:
517497 def _cancel_show (self ) -> None :
518498 self ._cancel_timer ("show" )
519499
520- def show (self , event : Optional [tk .Event ] = None ) -> None : # noqa: ARG002 # pylint: disable=unused-argument
521- """On non-macOS, tooltip already exists, show it on events."""
522- self ._cancel_hide ()
523- self ._hide_active_tooltip ()
524- if self .tooltip :
525- self .position_tooltip ()
526- self .tooltip .deiconify ()
527- Tooltip ._active_tooltip = self
500+ # def show(self, event: Optional[tk.Event] = None) -> None: # pylint: disable=unused-argument
501+ # """On non-macOS, tooltip already exists, show it on events."""
502+ # self._cancel_hide()
503+ # self._hide_active_tooltip()
504+ # if self.tooltip:
505+ # self.position_tooltip()
506+ # self.tooltip.deiconify()
507+ # Tooltip._active_tooltip = self
528508
529509 def _cancel_hide (self , event : Optional [tk .Event ] = None ) -> None : # noqa: ARG002 # pylint: disable=unused-argument
530510 self ._cancel_timer ("hide" )
@@ -589,7 +569,7 @@ def create_show(self, event: Optional[tk.Event] = None) -> None: # noqa: ARG002
589569 "noActivates" ,
590570 )
591571 self .tooltip .configure (bg = "#ffffe0" )
592- except AttributeError : # Catches protected member access error
572+ except ( AttributeError , tk . TclError ) : # Catches protected member access error
593573 self .tooltip .wm_attributes ("-alpha" , 1.0 ) # Ensure opacity
594574 self .tooltip .wm_attributes ("-topmost" , True ) # Keep on top # noqa: FBT003
595575 self .tooltip .configure (bg = "#ffffe0" )
@@ -652,30 +632,27 @@ def position_tooltip(self) -> None:
652632 # Silently ignore - tooltip will be recreated on next hover if needed
653633 pass
654634
655- def hide (self , event : Optional [tk .Event ] = None ) -> None : # noqa: ARG002 # pylint: disable=unused-argument
656- """Hide the tooltip after a delay on non-macOS."""
657- self ._cancel_hide ()
658- self .timers ["hide" ] = self .widget .after (TOOLTIP_HIDE_DELAY_MS , self ._do_hide )
635+ # def hide(self, event: Optional[tk.Event] = None) -> None: # pylint: disable=unused-argument
636+ # """Hide the tooltip after a delay on non-macOS."""
637+ # self._cancel_hide()
638+ # self.timers["hide"] = self.widget.after(TOOLTIP_HIDE_DELAY_MS, self._do_hide)
659639
660- def _do_hide (self ) -> None :
661- """Actually hide or destroy the tooltip depending on platform."""
662- if self .tooltip :
663- self .tooltip .withdraw ()
664- if Tooltip ._active_tooltip is self :
665- Tooltip ._active_tooltip = None
666- self .timers .pop ("hide" , None )
640+ # def _do_hide(self) -> None:
641+ # """Actually hide or destroy the tooltip depending on platform."""
642+ # if self.tooltip:
643+ # self.tooltip.withdraw()
644+ # if Tooltip._active_tooltip is self:
645+ # Tooltip._active_tooltip = None
646+ # self.timers.pop("hide", None)
667647
668648 def force_hide (self ) -> None :
669649 """Immediately hide or destroy the tooltip, depending on platform."""
670650 self ._cancel_show ()
671651 self ._cancel_hide ()
672652 self ._cancel_timer ("alpha" )
673653 if self .tooltip :
674- if platform_system () == "Darwin" :
675- self .tooltip .destroy ()
676- self .tooltip = None
677- else :
678- self .tooltip .withdraw ()
654+ self .tooltip .destroy ()
655+ self .tooltip = None
679656 if Tooltip ._active_tooltip is self :
680657 Tooltip ._active_tooltip = None
681658
0 commit comments