Python Tkinter – ScrolledText Widget
Tkinter is a built-in standard python library. With the help of Tkinter, many GUI applications can be created easily. There are various types of widgets available in Tkinter such as button, frame, label, menu, scrolledtext, canvas and many more. A widget is an element that provides various controls. ScrolledText widget is a text widget with a scroll bar. The tkinter.scrolledtext module provides the text widget along with a scroll bar. This widget helps the user enter multiple lines of text with convenience. Instead of adding a Scroll bar to a text widget, we can make use of a scrolledtext widget that helps to enter any number of lines of text.
# Python program demonstrating # ScrolledText widget in tkinter import tkinter as tk from tkinter import ttk from tkinter import scrolledtext # Creating tkinter main window win = tk.Tk() win.title("ScrolledText Widget") # Title Label ttk.Label(win, text = "ScrolledText Widget Example insert", font = ("Times New Roman", 15), background = 'green', foreground = "white").grid(column = 0, row = 0) # Creating scrolled text # area widget text_area = scrolledtext.ScrolledText(win, wrap = tk.WORD, width = 50, height = 10, font = ("Times New Roman", 15)) text_area.grid(column = 0, row=1, pady = 10, padx = 10) # Placing cursor in the text area #text_area.focus() # Inserting Text which is read only text_area.insert(tk.INSERT, """ This is a scrolledtext widget to make tkinter text read only. Hi Geeks !!! Geeks !!! Geeks !!! Geeks !!! Geeks !!! Geeks !!! Geeks !!! """) # Making the text read only text_area.configure(state ='disabled') win.mainloop()
コメント
コメントを投稿