1

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?

Kevin Mayo
  • 1,089
  • 6
  • 19
  • The literal answer to the question _"How to set scrollText border in tkinter?"_ is "the same as with any other widget, using the `borderwidth` and `relief` options". Have you tried using those? – Bryan Oakley Jan 17 '20 at 15:52
  • @BryanOakley yes,OK.I try to use ```relief```.(The Tkinter Text Widget)[https://effbot.org/tkinterbook/text.htm].it has SUNKEN, RAISED, GROOVE, RIDGE, FLAT.but all of them can not have border in all the direction at the same time. – Kevin Mayo Jan 17 '20 at 16:00
  • Correct - to get a sunken or raised relief requires that the top and left edges look different than the bottom and right edges. – Bryan Oakley Jan 17 '20 at 16:08

1 Answers1

1

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()
jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49