टिंकर लाइब्रेरी में कई अंतर्निहित कार्य और विधियां हैं जिनका उपयोग किसी एप्लिकेशन के कार्यात्मक भाग को लागू करने के लिए किया जा सकता है। हम संदेशबॉक्स . का उपयोग कर सकते हैं विभिन्न पॉपअप संवाद बॉक्स बनाने के लिए टिंकर में मॉड्यूल। संदेश बॉक्स प्रॉपर्टी में विभिन्न प्रकार की बिल्ट-इन पॉपअप विंडो होती हैं जिनका उपयोग उपयोगकर्ता अपने एप्लिकेशन में कर सकते हैं।
यदि आपको त्रुटि प्रदर्शित करने की आवश्यकता है संदेशबॉक्स अपने आवेदन में, आप showerror("Title", "Error Message") . का उपयोग कर सकते हैं तरीका। इस विधि को संदेशबॉक्स . के साथ लागू किया जा सकता है स्वयं।
उदाहरण
# Import the required libraries
from tkinter import *
from tkinter import messagebox
# Create an instance of tkinter frame or window
win = Tk()
# Set the size of the tkinter window
win.geometry("700x350")
# Define a function to show the error message
def on_click():
messagebox.showerror('Python Error', 'Error: This is an Error Message!')
# Create a label widget
label = Label(win, text="Click the button to show the message ",
font=('Calibri 15 bold'))
label.pack(pady=20)
# Create a button to delete the button
b = Button(win, text="Click Me", command=on_click)
b.pack(pady=20)
win.mainloop() आउटपुट
जब आप उपरोक्त कोड चलाते हैं, तो यह विंडो में एक बटन विजेट और एक लेबल दिखाएगा। त्रुटि संदेश दिखाने के लिए बटन पर क्लिक करें।
