This is the part 2 of Text widget. In first part, we've learned how we can create Text widget and also learned the several option along with that.
So in this video, we're going to learn how we can get, insert, delete text from the Text using some methods.
The methods used in video are as follows-
1. .insert() - this methods used to insert the text into Text.
2. get() - this method is to get the text from Text.
3. selection_get() - this method is used to get the selected text.
4. search() - search method is used to search a perticular string and returns its postition.
5. delete() - delete method is used to clear the text from tkinter Text.
code used in the video-
from tkinter import *
def print_me():
result = text.selection_get()
pos = text.search(result, 1.0, stopindex=END)
print(pos)
print(result)
root = Tk()
text = Text(root, width=20, height=10, wrap=WORD, padx=10, pady=10, bd=5, selectbackground="blue")
text.pack()
text.insert(INSERT, "hello iam indrajeet")
button = Button(root, text="print me", command=print_me).pack()
root.geometry("300x300+120+120")
root.mainloop()
------------------------------------------------
I'm sure your quries like -
how to insert text into Text in tkinter?
how to fetch the text from Text in Tkinter?
how to get selected text in Tkinter Text widget?
how to search text in Text in tkinter?
how to clear Text in TKinter?
have been solved.
if you have any problem related with this video, then please let us know in comment box. we'll reply as soon as possible.
Contact us -
FB - / programmingacage
email - techgramacademy@gmail.com
In questa pagina del sito puoi guardare il video online Python GUI Tutorial - 32 - Text - part2 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Indrajeet Singh 29 luglio 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 5,847 volte e gli è piaciuto 45 spettatori. Buona visione!