简体   繁体   English

Tkinter - 如何在 ScrolledText 小部件中添加边框?

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

By default the Text and ScrolledText widgets don't have a border in the right and in the lower side.默认情况下, TextScrolledText小部件的右侧和下方没有边框。 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:我也附上了截图:

在此处输入图片说明

You can add borders to frames with the highlightborder and highlightthickness parameters when creating the frame.创建框架时,您可以使用highlightborderhighlightthickness参数为框架添加边框。

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM