title | Title of the alert window . |
text | Message or text to be displayed on alert window. |
duration | In Milli seconds, to show the message. If not provided then window closes on click. |
bootstyle | Style keyword, options are primary, secondary, success,info,warning,danger, light, dark |
alert | True / False : To sound the alert beep while displaying the window. |
icon | A unicode character to display on the top-left hand corner of the toast. |
iconfont | The font used to render the icon. |
position | tuple ( x, y, anchor ). 'ne' is the anchor by default. n, e, s, w, nw, ne, sw, se |
**kwargs | Other keyword arguments. |
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()
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