在Tkinter中,所请求的功能不叫做"border"(边框),而是叫做"highlight"(高亮)。
要实现上述功能,请设置highlightbackground="black"
和highlightthickness=1
。
(边框是围绕框架保留的空白空间。有关更多信息,请参见文档。)
import tkinter as tk
#tk.Frame(master, **config-options)
my_frame = tk.Frame(parent_widget, borderwidth = 1)
from tkinter import *
root = Tk()
frame1 = Frame(root, highlightbackground="blue", highlightthickness=1,width=600, height=100, bd= 0)
frame1.pack()
root.mainloop()
根据需要更改选项
highlightbackground 用于更改聚焦小部件的颜色
highlightthickness 用于指定聚焦小部件周围边框的粗细。
我已经尝试过:
frame_left = tk.Frame(window, width=100, height=360, bg="blue", borderwidth=1, relief=tk.RIDGE)
frame_left.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
frame_right = tk.Frame(window, highlightbackground="green", highlightthickness=10, width=100, height=100, bd=0)
frame_right.pack(side=tk.RIGHT, fill=tk.BOTH, expand=1)
root.config()
。root.configure(background= "#ffffff", borderwidth =2)
from tkinter import *
root = Tk()
frame1 = Frame(root, width=400, height=660, bg="White", borderwidth=1, relief=RIDGE)
frame1.place(relx=0.7, y=80)
root.mainloop()