- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to word-wrap text in Tkinter Text?
Word Wrapping plays a significant role in any textual information. It is an important feature for any text editor which breaks the section of a particular text to fit into multiple sections of lines where possible. It is used to fit the content in the width of a text document. In Tkinter, we can wrap the words or chars in the text widget using the wrap property. The default values for the wrap properties are – WORD, CHARS, or NONE.
In this example, we will wrap all the words of a text widget using the wrap property.
#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame or window win= Tk() #Set the geometry of tkinter frame win.geometry("750x250") #Create a text widget and wrap by words text= Text(win,wrap=WORD) text.insert(INSERT,"Python is an interpreted, high-level and general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation.") text.pack() win.mainloop()
Running the above code will display a window containing some text. The text is wrapped by words which helps the user to read the document or text file easily.
- How can we implement line wrap and word wrap text inside a JTextArea in Java?
- How to wrap the text in text flow layout in JavaFX?
- How to highlight text in a tkinter Text widget?
- Adding coloured text to selected text in Tkinter
- Wrap Strings of Text in Bootstrap Navbar
- How to wrap the text of a label in JavaFX?
- How do I center the text in a Tkinter Text widget?
- How to get the Tkinter Label text?
- How to insert text at the beginning of the text box in Tkinter?
- How To Dynamically Resize Button Text in Tkinter?
- How to change text cursor color in Tkinter?
- How to set font for Text in Tkinter?
- Word Wrap Problem
- How to take input in a text widget and display the text in tkinter?
- How to get the current length of the Text in a Tkinter Text widget?