हम टेक्स्ट डालने, जानकारी प्रदर्शित करने और टेक्स्ट विजेट से आउटपुट प्राप्त करने के लिए टिंकर टेक्स्ट विजेट का उपयोग कर सकते हैं। टेक्स्ट विजेट में उपयोगकर्ता इनपुट प्राप्त करने के लिए, हमें get() . का उपयोग करना होगा तरीका। आइए एक उदाहरण लेते हैं कि यह कैसे काम करता है।
उदाहरण
# Import the required library
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame
win=Tk()
# Set the geometry
win.geometry("700x350")
def get_input():
label.config(text=""+text.get(1.0, "end-1c"))
# Add a text widget
text=Text(win, width=80, height=15)
text.insert(END, "")
text.pack()
# Create a button to get the text input
b=ttk.Button(win, text="Print", command=get_input)
b.pack()
# Create a Label widget
label=Label(win, text="", font=('Calibri 15'))
label.pack()
win.mainloop() आउटपुट
उपरोक्त कोड को चलाने पर एक टेक्स्ट विजेट वाली विंडो प्रदर्शित होगी। टेक्स्ट विजेट में कुछ टाइप करें और "प्रिंट करें" . पर क्लिक करें आउटपुट प्रदर्शित करने के लिए बटन।
