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
-
- import tkinter as tk
- from tkinter import ttk
- from tkinter import scrolledtext
- win = tk.Tk()
- win.title("Python GUI App")
- ttk.Label(win, text="This is Scrolled Text Area").grid(column=0,row=0)
-
- scrolW=30
- scrolH=2
- scr=scrolledtext.ScrolledText(win, width=scrolW, height=scrolH, wrap=tk.WORD)
- scr.grid(column=0, columnspan=3)
-
- 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