title: Tkinter Tooltip over a text only in a text widget
body: <p><strong><em>Description</em></strong>:</p>
  
  <p>I have a text widget which contains some text.
  I want a tooltip over a word. Like, for a specific word, tooltip #1 and for other, tooltip #2, and so on.
  When I tried to create one tooltip for a single word, it actually created a tooltip for the entire text widget. I know the reason because I passed the Text widget to the HoverInfo class.</p>
  
  <hr>
  
  <p><strong><em>My Question:</em></strong> </p>
  
  <ul>
  <li>How can I create a tooltip for a word in a text widget?</li>
  <li>And is it possible to define multiple tooltips dynamically for different words in a text widget?</li>
  </ul>
  
  <hr>
  
  <p>My code for the <strong><em>Description</em></strong>:</p>
  
  <pre><code>from tkinter import *
  import re
  import tkinter as tk
  
  class HoverInfo(Menu):
      def __init__(self, parent, text, command=None):
         self._com = command
         Menu.__init__(self,parent, tearoff=0)
         if not isinstance(text, str):
            raise TypeError('Trying to initialise a Hover Menu with a non string type: ' + text.__class__.__name__)
         toktext=re.split('\n', text)
         for t in toktext:
            self.add_command(label = t)
            self._displayed=False
            self.master.bind("&lt;Enter&gt;",self.Display )
            self.master.bind("&lt;Leave&gt;",self.Remove )
  
      def __del__(self):
         self.master.unbind("&lt;Enter&gt;")
         self.master.unbind("&lt;Leave&gt;")
  
      def Display(self,event):
         if not self._displayed:
            self._displayed=True
            self.post(event.x_root, event.y_root)
         if self._com != None:
            self.master.unbind_all("&lt;Return&gt;")
            self.master.bind_all("&lt;Return&gt;", self.Click)
  
      def Remove(self, event):
       if self._displayed:
         self._displayed=False
         self.unpost()
       if self._com != None:
         self.unbind_all("&lt;Return&gt;")
  
      def Click(self, event):
         self._com()
  
  
  
  def HelloWorld():
      print('Hello World')
  
  
  def vp_start_gui():
      global val, w, root, o
      root = Tk()
      canvas = tk.Canvas(root)
      scroll = tk.Scrollbar(root, orient='horizontal', command=canvas.xview)
      canvas.configure(xscrollcommand=scroll.set)
      frame = tk.Frame(canvas) # frame does not get pack() as it needs to be embedded into canvas throught canvas.
      scroll.pack(side='bottom', fill='x')
      canvas.pack(fill='both', expand='yes')
      canvas.create_window((0,0), window=frame, anchor='nw')
      frame.bind('&lt;Configure&gt;', lambda x: canvas.configure(scrollregion=canvas.bbox('all'))) # lambda function
  
      journal = tk.Text(frame, width = 75, height = 39)
      journal.configure(background="#f2f2f2")
      journal.configure(borderwidth="3")
      journal.configure(relief="groove")
      journal.grid() # grid instead
      journal.insert("end", "I want tooltip over this text only")    
      hover = HoverInfo(journal,'while hovering press return \n for an exciting msg', HelloWorld)
  
  
      root.mainloop()    
  
  
  if __name__ == '__main__':
      vp_start_gui()
  </code></pre>