How do I display tooltips in Tkinter?


Tooltips are useful in applications where we need to display some information while hovering on a button.

In order to create and display a tooltip, we can use the Balloon property of tkinter.

Example

#Import the tkinter library
from tkinter import *
from tkinter.tix import *

#Create an instance of tkinter frame
win = Tk()
#Set the geometry
win.geometry("600x450")

#Create a tooltip
tip = Balloon(win)

#Create a Button widget
my_button=Button(win, text= "Hover Me")
my_button.pack(pady=20)

#Bind the tooltip with button
tip.bind_widget(my_button,balloonmsg="www.tutorialspoint.com")

win.mainloop()

Output

The above code will display the following window with a button "Hover Me". When the user hovers over the button, it will show a tooltip text.

Updated on: 27-Mar-2021

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements