Tkinter 10: Text widget

tkinter 10 text widgets

The text widget

With this tool you can add more text than in the usual entry widget. So, let’s see how does it works.

Example of use of the text widget in tkinter

"""text widget of tkinter

Creates a window with a text box
when you hit ctrl + s it will print the
content of the text box in the console
"""

from tkinter import Tk
import tkinter as tk


root = Tk()


def start(event):
    print(text.get("0.0", tk.END))


text = tk.Text(root)
text.pack()
text.bind("<Control - s>", start)
root.mainloop()

Video about tkinter’s widget text

Tkinter test for students

Tkinter articles

Advertisement