Using scrolled text widgets

ScrolledText widgets are much larger than simple Entry widgets and span multiple lines. They are widgets like Notepad and wrap lines, automatically enabling vertical scrollbars when the text gets larger than the height of the ScrolledText widget.

Getting ready

This recipe extends the previous recipes. You can download the code for each chapter of this book from the Packt Publishing website.

How to do it...

By adding the following lines of code, we create a ScrolledText widget:

# Add this import to the top of the Python Module # 1 from tkinter import scrolledtext # 2 # Using a scrolled Text control # 3 scrolW = 30 # 4 scrolH = 3 # 5 scr = scrolledtext.ScrolledText(win, width=scrolW, height=scrolH, wrap=tk.WORD) # 6 scr.grid(column=0, ...

Get Python GUI Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.