toast to show alert message

Ttkbootstrap toast
Showing alert message for a duration or close on click .


Parameters


titleTitle of the alert window .
textMessage or text to be displayed on alert window.
durationIn Milli seconds, to show the message. If not provided then window closes on click.
bootstyleStyle keyword, options are
primary, secondary, success,info,warning,danger, light, dark
alertTrue / False : To sound the alert beep while displaying the window.
iconA unicode character to display on the top-left hand corner of the toast.
iconfontThe font used to render the icon.
positiontuple ( x, y, anchor ). 'ne' is the anchor by default. n, e, s, w, nw, ne, sw, se
**kwargsOther keyword arguments.


Toast of Ttkbootstrap to show Help text with duration and position #15


import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.toast import ToastNotification

my_w = ttk.Window(themename="lumen")
my_w.geometry("300x200")  # width and height

toast = ToastNotification(
    title="This is title of Notification ",
    message="Welcome to plus2net.com to learn Python ",
    position=(400, 300, "ne"),
    alert=True,
    duration=5000,
    bootstyle=SUCCESS
)

toast.show_toast() # display the Toast Notification 

my_w.mainloop()

Using hide_toast() and show_toast().

Ttkbootstrap show hide toast Notification
On click of a button the toast will open by using show_toast() and by click of another button we can hide by using hide_toast().
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.toast import ToastNotification

my_w = ttk.Window(themename="lumen")
my_w.geometry("300x200")  # width and height

toast = ToastNotification(
    title="This is the title of Notification ",
    message="Welcom to plus2net.com to learn Python ",
    position=(400, 250, "ne"),
    bootstyle=DANGER
)
# toast.show_toast()
b1 = ttk.Button(
    my_w, text="Open Toast", command=lambda: toast.show_toast(), bootstyle=SUCCESS
)
b1.grid(row=1, column=1, padx=10, pady=30)
b2 = ttk.Button(
    my_w, text="Close Toast", command=lambda: toast.hide_toast(), bootstyle=DANGER
)
b2.grid(row=1, column=2, padx=10, pady=30)
my_w.mainloop()
Showing ToolTip on Mouse Hovering
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