Python Tkinter – MessageBox
Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create the GUI applications. Creating a GUI using tkinter is an easy task.
MessageBox Widget
Python Tkinter – MessageBox Widget is used to display the message boxes in the python applications. This module is used to display a message using provides a number of functions.
Syntax
messagebox.Function_Name(title, message [, options])
Function_Name: This parameter is used to represents an appropriate message box function.
title: This parameter is a string which is shown as a title of a message box.
message: This parameter is the string to be displayed as a message on the message box.
Option:There are two options that can be used are:
    1.Deault: This option is used to specify the default button like ABORT, RETRY, or IGNORE in the message box.
    2.Parent:This option is used to specify the window on top of which the message box is to be displayed.
Warning message boxes
-tkinter.messagebox.showerror(title=None, message=None, **options)
-tkinter.messagebox.showwarning(title=None, message=None, **options) Question message boxes
-tkinter.messagebox.askyesno(title=None, message=None, **options)
-tkinter.messagebox.askyesnocancel(title=None, message=None, **options)
-tkinter.messagebox.askokcancel(title=None, message=None, **options)
-tkinter.messagebox.askquestion(title=None, message=None, **options)
-tkinter.messagebox.askretrycancel(title=None, message=None, **options)
Information Message box
tkinter.messagebox.showinfo(title=None, message=None, **options)
Example
from tkinter import *
from PIL import ImageTk, Image
from tkinter import messagebox
root=Tk()
root.title('Knowledge Edcuation Cambodia')
root.iconbitmap('1.png')
root.geometry("300x400")
#showwarning, showinfo,showerror,askquestion,askyesno,askokcannel
def testing():
    indexmessage=messagebox.askyesno("Knowledge Education Cambodia","Do you want to Delete")
    Label(root, text=indexmessage).pack()
    if indexmessage==1:
        Label(root, text="Clicked Yes").pack()
    else:
        Label(root, text="Clicked No").pack()
Button(root, text="Testing",command=testing).pack()
root.mainloop()
Please Watching My Video is Below
No comments:
Post a Comment