ToolTip to show help text on Mouse hover

Ttkbootstrap Tooltip
Showing help text in a popup window when mouse is hovering over the widget and closes when mouse left the widget or the widget is clicked.


Parameters


textMessage or text to be displayed on popup window.
bootstyleStyle keyword, options are
primary, secondary, success,info,warning,danger, light, dark
wraplengthThe width of the popup window in screenunits before the text is wrapped to the next line.
**kwargsOther keyword arguments.


ToolTip of Ttkbootstrap to show Help text when mouse is over the widget #14


import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.tooltip import ToolTip

my_w = ttk.Window()
my_w.geometry("500x200")  # width and height

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()

Using hide_tip() and show_tip().

Ttkbootstrap Tooltip hide_tip() show_tip()
The ToolTip (tt1) for the first button ( b1) will display when the value of the Floodgauge is less than 25. Once it goes beyond 25 the ToolTip is hidden by using tt1.hide_tip(). It is displayed again by using tt1.show_tip().
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.tooltip import ToolTip

my_w = ttk.Window()
my_w.geometry("520x320")  # width and height

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()
Toast Notification
ttkbootstrap
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer