The ttkbootstrap ToolTip class displays a styled popup help window when the mouse hovers over a widget and closes automatically when the pointer leaves the widget or clicks it.
show_tip() & hide_tip()
Import ToolTip from ttkbootstrap.widgets and attach it to any target ttkbootstrap Button or widget using the Grid layout manager.
| Parameter | Description |
|---|---|
text |
Message or help text displayed inside the popup window. |
bootstyle |
Style keyword such as PRIMARY, SECONDARY, SUCCESS, INFO, WARNING, DANGER, LIGHT, DARK, or tuple combinations like (INFO, INVERSE). |
wraplength |
Maximum width of the popup window before text wraps onto the next line. |
**kwargs |
Additional keyword arguments passed to the underlying tooltip configuration. |
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.widgets import ToolTip
my_w = ttk.Window()
my_w.geometry("500x200")
b1 = ttk.Button(my_w, text="Start", bootstyle=SUCCESS)
b1.grid(row=2, column=1, padx=40, pady=40)
b2 = ttk.Button(my_w, text="Stop", bootstyle=DANGER)
b2.grid(row=2, column=2, padx=40, pady=40)
b3 = ttk.Button(my_w, text="Jump", bootstyle=PRIMARY)
b3.grid(row=2, column=3, padx=40, pady=40)
b4 = ttk.Button(my_w, text="Reset", bootstyle=WARNING)
b4.grid(row=2, column=4, padx=40, pady=40)
tt1 = ToolTip(b1, text="This is to Start", bootstyle=(INFO, INVERSE))
tt2 = ToolTip(b2, text="This is Stop the Project", bootstyle=DANGER)
tt3 = ToolTip(b3, text="This is Jump the Project", bootstyle=(SUCCESS, INVERSE))
tt4 = ToolTip(
b4, text="This is Reset the Project", wraplength=100, bootstyle=(SECONDARY, INVERSE)
)
my_w.mainloop()
show_tip() & hide_tip()
In this example, the tooltip (tt1) on the Start button is shown when the Floodgauge value is below 25 using tt1.show_tip(), and hidden once progress moves into higher ranges using tt1.hide_tip().
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.widgets import ToolTip
my_w = ttk.Window()
my_w.geometry("520x320")
fg = ttk.Floodgauge(
bootstyle=INFO,
mask="Progress {}%",
value=10,
length=500,
)
fg.grid(row=1, column=1, padx=10, pady=50, columnspan=4)
b1 = ttk.Button(my_w, text="Start", command=lambda: fg.start(), bootstyle=SUCCESS)
b1.grid(row=2, column=1, padx=10, pady=40)
b2 = ttk.Button(my_w, text="Stop", command=lambda: fg.stop(), bootstyle=DANGER)
b2.grid(row=2, column=2, padx=10, pady=40)
b3 = ttk.Button(my_w, text="Jump", command=lambda: fg.step(5), bootstyle=PRIMARY)
b3.grid(row=2, column=3, padx=10, pady=40)
b4 = ttk.Button(
my_w, text="Reset", command=lambda: fg.configure(value=10), bootstyle=WARNING
)
b4.grid(row=2, column=4, padx=10, pady=40)
def my_upd(*args):
if fg.variable.get() < 25:
fg.configure(bootstyle=INFO)
tt1.show_tip()
elif fg.variable.get() < 50:
fg.configure(bootstyle=SUCCESS)
tt1.hide_tip()
elif fg.variable.get() < 80:
fg.configure(bootstyle=WARNING)
else:
fg.configure(bootstyle=DANGER)
fg.variable.trace("w", my_upd)
tt1 = ToolTip(b1, text="This is Started", bootstyle=(INFO, INVERSE))
tt2 = ToolTip(b2, text="This will Stop the Project", bootstyle=DANGER)
tt3 = ToolTip(b3, text="This is to Jump the Project", bootstyle=(SUCCESS, INVERSE))
tt4 = ToolTip(
b4, text="This is Reset the Project", wraplength=100, bootstyle=(SECONDARY, INVERSE)
)
my_w.mainloop()

Using StringVar and Radiobutton widgets, you can switch themes at runtime with app.style.theme_use() and verify how ToolTip popups render across light and dark themes.
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.widgets import ToolTip
app = ttk.Window(title="ToolTip Theme Switcher", themename="bootstrap-light")
app.geometry("480x210")
theme_var = ttk.StringVar(value="bootstrap-light")
themes = ["bootstrap-light", "bootstrap-dark", "nord-light", "nord-dark"]
def change_theme():
selected = theme_var.get()
app.style.theme_use(selected)
lbl_status.config(text=f"Active Theme: {selected}")
ttk.Label(
app, text="Select Theme:", font=("Helvetica", 11, "bold")
).grid(row=0, column=0, columnspan=4, padx=15, pady=12, sticky="w")
for idx, t_name in enumerate(themes):
ttk.Radiobutton(
app,
text=t_name,
value=t_name,
variable=theme_var,
command=change_theme,
bootstyle="outline-toolbutton"
).grid(row=1, column=idx, padx=5, pady=5)
btn_save = ttk.Button(app, text="Save Settings", bootstyle=SUCCESS)
btn_save.grid(row=2, column=0, columnspan=2, padx=15, pady=20)
ToolTip(btn_save, text="Persist current preferences to disk", bootstyle=(INFO, INVERSE))
lbl_status = ttk.Label(app, text="Active Theme: bootstrap-light", bootstyle=INFO)
lbl_status.grid(row=2, column=2, columnspan=2, padx=15, pady=20, sticky="w")
app.mainloop()
'darkly' and 'cosmo' still work in 2.x for backward compatibility but emit a DeprecationWarning and are planned for removal in 3.0. In ttkbootstrap 2.x, prefer <family>-light and <family>-dark theme names (such as 'bootstrap-light', 'bootstrap-dark', 'nord-light', or 'nord-dark'), or inspect available names via app.style.theme_names().
In data-entry forms or configurable desktop utilities, storing tooltip guidance in an SQLite database via SQLAlchemy lets you update field hints centrally without changing GUI code.
from sqlalchemy import create_engine, text
DATABASE_URL = "sqlite:///tooltip_hints.db"
engine = create_engine(DATABASE_URL, echo=False)
with engine.connect() as conn:
conn.execute(text("""
CREATE TABLE IF NOT EXISTS field_hints (
field_key TEXT PRIMARY KEY,
hint_text TEXT NOT NULL
)
"""))
count = conn.execute(text("SELECT COUNT(*) FROM field_hints")).scalar()
if count == 0:
conn.execute(text("""
INSERT INTO field_hints (field_key, hint_text) VALUES
('student_name', 'Enter full student name as printed on ID card'),
('student_grade', 'Enter grade code such as A, B, or C')
"""))
conn.commit()
print("Tooltip hints table ready.")
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.widgets import ToolTip
from sqlalchemy import create_engine, text
DATABASE_URL = "sqlite:///tooltip_hints.db"
engine = create_engine(DATABASE_URL, echo=False)
def get_hint(field_key, fallback):
with engine.connect() as conn:
row = conn.execute(
text("SELECT hint_text FROM field_hints WHERE field_key = :k"),
{"k": field_key}
).fetchone()
return row[0] if row else fallback
app = ttk.Window(title="Database ToolTip Hints", themename="bootstrap-light")
app.geometry("440x180")
ttk.Label(app, text="Student Name:").grid(row=0, column=0, padx=15, pady=15, sticky="w")
ent_name = ttk.Entry(app, width=28)
ent_name.grid(row=0, column=1, padx=10, pady=15)
ToolTip(ent_name, text=get_hint("student_name", "Enter student name"), wraplength=220)
ttk.Label(app, text="Grade:").grid(row=1, column=0, padx=15, pady=15, sticky="w")
ent_grade = ttk.Entry(app, width=28)
ent_grade.grid(row=1, column=1, padx=10, pady=15)
ToolTip(ent_grade, text=get_hint("student_grade", "Enter grade"), wraplength=220)
app.mainloop()
To read shared tooltip hints from a centralized MySQL database server, update DATABASE_URL to use PyMySQL while keeping the same SQLAlchemy query pattern:
# SQLite Connection (Commented Out)
# DATABASE_URL = "sqlite:///tooltip_hints.db"
# MySQL Connection string using PyMySQL
DATABASE_URL = "mysql+pymysql://username:password@localhost/student_db"
engine = create_engine(DATABASE_URL, echo=False)
| Issue / Error | Cause | Recommended Solution |
|---|---|---|
| ModuleNotFoundError: No module named 'ttkbootstrap.tooltip' | Using the legacy ttkbootstrap.tooltip submodule path removed in ttkbootstrap 2.x. |
Import from ttkbootstrap.widgets: from ttkbootstrap.widgets import ToolTip. |
| Long tooltip text stretches too wide across screen | No wraplength value was provided for a longer help string. |
Pass wraplength=180 (or another suitable width) to wrap text cleanly. |
Programmatic show_tip() / hide_tip() behaves unexpectedly |
Called before widgets are laid out or on a hidden/unmapped widget. | Trigger show_tip() and hide_tip() inside event callbacks or variable traces after creating the widget and ToolTip instance. |
ToolTip closes when the mouse pointer leaves the target widget or when the user clicks the widget.
ttkbootstrap widget—such as Entry, Label, Combobox, Checkbutton, or Floodgauge—as the first argument to ToolTip(widget, text=...).
ToolTip(...) instance to a variable (such as tt1) and call tt1.show_tip() or tt1.hide_tip() when application state changes.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.