Kevin Mayo
Kevin Mayo

Reputation: 1159

How to set scrollText border in tkinter?

I am new to tkinter. My code likes this,

import tkinter
from tkinter import scrolledtext

Win = tkinter.Tk()
Text = scrolledtext.ScrolledText(Win)
Text.pack(padx=10,pady=10)
Win.mainloop()

As you can see,it only have the left border,top border. However,it haven't right border and bottom border.

I have watched this How to set border color of certain Tkinter widgets?. And I have tried highlightbackground=color, the code is this

import tkinter
from tkinter import scrolledtext

Win = tkinter.Tk()
Text = scrolledtext.ScrolledText(Win)
Text.config(highlightbackground="black")
Text.pack(padx=10,pady=10)
Win.mainloop()

it also didn't work.it made no difference.

In this document:tkinter.scrolledtext — Scrolled Text Widget,I know that the constructor is the same as that of the tkinter.Text class.And I have seen The Tkinter Text Widget,But it didn't have config about the tkinter.Text border.

What should I do?

Upvotes: 1

Views: 861

Answers (1)

jizhihaoSAMA
jizhihaoSAMA

Reputation: 12672

it only have the left border,top border.

Because the widget config is relief="sunken", So you can try relief="solid".

So this is may solve your problem

import tkinter
from tkinter import scrolledtext

Win = tkinter.Tk()
Text = scrolledtext.ScrolledText(Win,relief="solid")
Text.pack(padx=10,pady=10)
Win.mainloop()

Upvotes: 1

Related Questions