TkinterServer Side ProgrammingProgramming

#### Mastering Python GUI with Tkinter

16 Lectures 2 hours

#### GUI Programming with Python Tkinter and Java Swing

30 Lectures 3.5 hours

#### Build A Paint Program With TKinter and Python

24 Lectures 1.5 hours

Tkinter text widget is much more than just a multiline text editor. It is useful for many applications where user interaction is required.

In order to configure the text widget, tkinter provides many functions and methods. Some of the features that we can add to style the text widgets are: changing the font-family, background-color, foreground-color, adding and selecting a particular text, changing font-size, and many more.

## Example

In this example, we will see how we can add different features to a particular text widget,

#Import tkinter library
from tkinter import *

#Create an instance of tkinter frame
win = Tk()

#Set the geometry of tkinter window
win.geometry("750x250")

#Create a text widget
text= Text(win, width= 50, height=14)

#Set default text for text widget
text.insert(INSERT, "Tkinter is a Python Library which is used to create various types of applications.")
text.insert(END, "Learning Tkinter is Awesome!!")

text.tag_configure("start", background= "OliveDrab1", foreground= "black")

#Configure the Text Style
text.configure(font=('Times New Roman',15))
text.pack()
win.mainloop()

## Output

Running the above code will display a window containing a text widget with some features and properties.

Updated on 15-Apr-2021 13:06:12