हम टिंकर पाठ . का उपयोग कर सकते हैं मल्टीलाइन उपयोगकर्ता इनपुट स्वीकार करने के लिए विजेट। हम टेक्स्ट सम्मिलित कर सकते हैं, जानकारी प्रदर्शित कर सकते हैं और टेक्स्ट विजेट से आउटपुट प्राप्त कर सकते हैं।
टेक्स्ट विजेट में वर्तमान में चयनित टेक्स्ट को हाइलाइट करने के लिए, हम tag_add() . का उपयोग कर सकते हैं विधि जो केवल वर्तमान पाठ में एक टैग जोड़ती है।
उदाहरण
# Import the required library
from tkinter import *
# Create an instance of tkinter frame
win=Tk()
# Set the geometry
win.geometry("700x350")
# Add a text widget
text=Text(win, width=80, height=15, font=('Calibri 12'))
# Set default text for text widget
text.insert(INSERT, "Tkinter is a Python Library to create GUI-based applications.")
text.insert(END, "Learning Tkinter is Awesome!!")
# Select Text by adding tags
text.tag_add("start", "1.0","1.7")
text.tag_configure("start", background="OliveDrab1", foreground="black")
text.pack()
win.mainloop() आउटपुट
उपरोक्त कोड को चलाने से एक टेक्स्ट विजेट के साथ एक विंडो प्रदर्शित होगी जिसमें हाइलाइट किया गया टेक्स्ट होगा।
