- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 code the tkinter "scrolledtext" module?
A widget in a Tkinter application can be configured easily by adding extensions and properties to it. The Text widget in tkinter is used to accept multiline user input. We can make the text inside the Text widget Scrollable by adding a scrollbar to it.
The ScrolledText Widget is also available in Tkinter Library. It is the combination of Text widget and Scrollbar widget which provides features like scrolling the text in an application. In order to use ScrolledText widget in an application, you must import it first. The scrolledtext widget works similar to the standardText widget. It includes all the properties and attributes that can be used extensively in the widget.
Example
# Import the tkinter library from tkinter import * from tkinter.scrolledtext import ScrolledText from lorem_text import lorem # Create an instance of tkinter frame win= Tk() # Set the size of the Tkinter window win.geometry("700x350") # Set the title of the window win.title("Scrolled Text") # Add ScrolledText widget size= 10 text= ScrolledText(win, width=40, height= 50) text.insert(END, lorem.paragraphs(10)) text.pack(fill= BOTH, side= LEFT, expand= True) win.mainloop()
Output
Executing the above code will display a multiline Text widget. The text inside the Text widget are scrollable. We can see even better output by adding wrapping feature in it.
- Related Articles
- Python Generate QR Code using pyqrcode module?
- How to bring a dialog box to appear at the front in a Tkinter module of Python?
- Changing the background color of a tkinter window using colorchooser module
- How to uninstall the PowerShell Module?
- How would I make destroy() method in Tkinter work with my code?
- How do you run your own code alongside Tkinter's event loop?
- Which function of scipy.cluster.vq module is used to assign codes from a code book to observations?
- How to install PowerShell Module?
- How to install the latest PowerShell module version?
- How to install the PowerShell Active Directory module?
- How to use the Subprocess Module in Python?
- How to retrieve Python module path?
- How to write a python module?
- How to install a Python Module?
- How to develop a Python Module?
