如何为Tkinter的python中的按钮添加边框?

Ana*_*k17 1 python tkinter button

b1 = Button(tk, text=" ", font=("Consolas 30 bold"), height = 1, width = 4,bg = "white", command=lambda:checker(b1))
Run Code Online (Sandbox Code Playgroud)

我要添加什么代码来为按钮添加边框,使其变粗?

gll*_*lls 5

根据http://effbot.org/tkinterbook/button.htm

borderwidth= variable
Run Code Online (Sandbox Code Playgroud)

按钮边框的宽度。默认值是特定于平台的,但通常是 1 或 2 个像素。(边框宽度/边框宽度)

不要与:

highlightthickness= variable
Run Code Online (Sandbox Code Playgroud)

高亮边框的宽度。默认值是系统特定的(通常是一两个像素)。(highlightThickness/HighlightThickness)

  • `highlightthickness` 与边框不同,它更像是按钮周围的环。边框由“borderwidth”和“relief”控制。 (5认同)