- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 force Tkinter text widget to stay on one line?
Tkinter text widget can be configured by using the configure(**options) function. We can use it to configure the background color, foreground color, wrapping and other properties of the text widget.
The wrap properties of the Text widget describe that the cursor changes its position whenever it detects a new line. However, in Tkinter, the text widget can be wrapped by words and characters. In order to make our text widget to stay in one line, we can use wrap=None property.
Example
# Import the required libraries from tkinter import * import lorem # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Add a Text widget text=Text(win, width=60, height=20) text.pack() # Add Some text into it text.insert(END,lorem.sentence()) # Configure the text widget to make the text sticky on one line text.configure(wrap=None) win.mainloop()
Output
Running the above code will display a text widget that will have its text wrapped to None.
- Related Articles
- How to highlight the current line of a Text widget in Tkinter?
- How to highlight text in a tkinter Text widget?
- How to clear Text widget content while clicking on the Entry widget itself in Tkinter?
- Change the focus from one Text widget to another in Tkinter
- How to add padding to a tkinter widget only on one side?
- How to make the Tkinter text widget read only?
- How to erase everything from the Tkinter text widget?
- How to create hyperlink in a Tkinter Text widget?
- How to erase everything from a Tkinter text widget?
- How to attach a Scrollbar to a Text widget in Tkinter?
- How to set default text for a Tkinter Entry widget?
- How to get the input from the Tkinter Text Widget?
- How to clear the contents of a Tkinter Text widget?
- How to attach a vertical scrollbar in Tkinter text widget?
- Add advanced features to a tkinter Text widget

Advertisements