टिंकर टेक्स्ट विजेट एक मल्टीलाइन टेक्स्ट इनपुट विजेट है। इसका उपयोग इनपुट क्षेत्र में टेक्स्ट डेटा डालने, हटाने और जोड़ने के लिए किया जाता है। यह अपने विजेट वर्ग में कई अंतर्निहित कार्य और विशेषताएँ प्रदान करता है।
टिंकर टेक्स्ट विजेट के केंद्र में टेक्स्ट को कॉन्फ़िगर और संरेखित करने के लिए, हम justify=CENTER का उपयोग कर सकते हैं संपत्ति।
उदाहरण
# Import the required libraries
from tkinter import *
# Create an instance of tkinter frame or window
win=Tk()
# Set the size of the window
win.geometry("700x350")
text=Text(win)
# Configure the alignment of the text
text.tag_configure("tag_name", justify='center')
# Insert a Demo Text
text.insert("1.0", "How do I center align the text " "in a Tkinter Text widget?")
# Add the tag in the given text
text.tag_add("tag_name", "1.0", "end")
text.pack()
win.mainloop() आउटपुट
टेक्स्ट विजेट के केंद्र में नमूना टेक्स्ट वाली विंडो प्रदर्शित करने के लिए उपरोक्त कोड चलाएँ।
