- 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 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.
# 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()
Running the above code will display a text widget that will have its text wrapped to None.
- How to highlight the current line of a Text widget in Tkinter?
- How to highlight text in a tkinter Text widget?
- How to add padding to a tkinter widget only on one side?
- Change the focus from one Text widget to another in Tkinter
- How to clear Text widget content while clicking on the Entry widget itself in Tkinter?
- How to make the Tkinter text widget read only?
- How to erase everything from the Tkinter text widget?
- How to erase everything from a Tkinter text widget?
- How to create hyperlink in a Tkinter Text widget?
- Add advanced features to a tkinter Text widget
- Printing a list to a Tkinter Text widget
- 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?