Uzzee Uzzee - 1 year ago 112
Python Question

Border for tkinter Label

Not really relevant but i'm building a calendar and I have a lot of Label widgets, and therefore it will look alot nicer if I had some borders for them!

I have seen you can do this for other widgets such as Button, Entry and Text.

Minimal code:

from tkinter import *

root = Tk()

L1 = Label(root, text="This")
L2 = Label(root, text="That")


I have tried setting


inside the widget, but still the same result.

example pic tkinter

Is this even possible to do? Thank you!

Answer Source

If you want a border, the option is borderwidth. You can also choose the relief of the border ("flat", "raised", "sunken", "ridge", "solid", "groove"):

l1 = Label9root, text="This", borderwidth=2, relief="groove")

Note: "ridge" and "groove" require at least two pixels of width to render properly

examples of tkinter borders