About Lesson
In this TKinter Tutorial we are going to learn about TKinter ScrollText, tkinter scrolltext is like a text widget with scroll bars.
This is the complete code for this lesson.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from tkinter import * import tkinter as tk from tkinter import scrolledtext class Window(Tk): def __init__(self): super(Window, self).__init__() self.title("ScrollTextControl In TKinter") self.minsize(500,400) self.wm_iconbitmap("myicon.ico") self.create_scrolltext() def create_scrolltext(self): scroll_w = 30 scroll_h = 10 scrollText = scrolledtext.ScrolledText(self, width = scroll_w, height = scroll_h, wrap = tk.WORD) scrollText.grid(column = 0, columnspan = 3) window = Window() window.mainloop() |
First you need to import the scrolledtext.
1 |
from tkinter import scrolledtext |
You can use this code for creating tkinter scrolltext.
1 2 |
scrollText = scrolledtext.ScrolledText(self, width = scroll_w, height = scroll_h, wrap = tk.WORD) |
You can add the scrolltext in a grid layout.
1 |
scrollText.grid(column = 0, columnspan = 3) |
Run the complete code and this will be the result.