Tkinter - How can I add a border in the ScrolledText widgets?

Viewed 247

By default the Text and ScrolledText widgets don't have a border in the right and in the lower side. How can I add the border where it miss?

Below an example code:

from tkinter import *
from tkinter import ttk, scrolledtext

parent = Tk()
parent.geometry("800x485+370+100")
parent.title("My Software")

WhiteFrame=Frame(parent, background="#ffffff")
WhiteFrame.pack()

TextObj=scrolledtext.ScrolledText(WhiteFrame, wrap=WORD, height=20)
TextObj.pack(padx=10, pady=10)

parent.mainloop()

I attached a screenshot too:

enter image description here

1 Answers

You can add borders to frames with the highlightborder and highlightthickness parameters when creating the frame.

from tkinter import *
from tkinter import ttk, scrolledtext

parent = Tk()
parent.geometry("800x485+370+100")
parent.title("My Software")

WhiteFrame=Frame(parent, background="#ffffff", highlightborder = 'black', highlightthickness = 1)
WhiteFrame.pack()

TextObj=scrolledtext.ScrolledText(WhiteFrame, wrap=WORD, height=20)
TextObj.pack(padx=10, pady=10)

parent.mainloop()
Related