How to do it...

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

  1. Start with the GUI_radiobutton_widget.py module and save it as GUI_scrolledtext_widget.py.

  1. Import scrolledtext:
from tkinter import scrolledtext
  1. Define variables for the width and height:
scrol_w = 30scrol_h = 3
  1. Create a ScrolledText widget:
scr = scrolledtext.ScrolledText(win, width=scrol_w, height=scrol_h, wrap=tk.WORD)
  1. Position the widget:
scr.grid(column=0, columnspan=3)

The preceding steps will finally produce the following code (GUI_scrolledtext_widget.py):

  1. Run the code. We can actually type into our widget, and if we type enough words, ...

Get Python GUI Programming Cookbook - Third Edition 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.