Introduction

In this blog, I am going to create a Scrolled Text widget in a Python GUI application. It will display the scrolled text area on the application screen.
Software requirement
Python 3.5 and IDLE (Python 3.5)
Programming code
  1. #Create Scrolled Text widget in Python GUI Application
  2. import tkinter as tk
  3. from tkinter import ttk
  4. from tkinter import scrolledtext
  5. win = tk.Tk()
  6. win.title("Python GUI App")
  7. ttk.Label(win, text="This is Scrolled Text Area").grid(column=0,row=0)
  8. #Create Scrolled Text
  9. scrolW=30
  10. scrolH=2
  11. scr=scrolledtext.ScrolledText(win, width=scrolW, height=scrolH, wrap=tk.WORD)
  12. scr.grid(column=0, columnspan=3)
  13. #Calling Main()
  14. win.mainloop()
About the code
  • First, I am importing the tkinter modules.
  • Next, I assign a class and variables and give the application title.
  • Next, I created the scrolled text area.
  • Finally, I have started the Windows event loop by calling the mainloop method.
  • And, I execute the code.
Output