Border for the tkinter tag

Not very relevant, but I create a calendar, and I have many Label widgets, and therefore it will be much better if I have borders for them!

I saw that you can do this for other widgets like Button, Entry and Text.

Minimum Code:

from tkinter import *

root = Tk()

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

L1.pack()
L2.pack()

I tried to configure

highlightthickness=4
highlightcolor="black"
highlightbackground="black"
borderwidth=4

inside the widget, but the result is the same.

example pic tkinter

Is it even possible to do this? Thank!

+15
source share
3 answers

If you want a frame, select an option borderwidth. You can also choose border relief: "flat", "raised", "sunken", "ridge", "solid"and "groove".

For instance:

l1 = Label(root, text="This", borderwidth=2, relief="groove")

. "ridge" "groove"

examples of tkinter borders

+51

@Pax Vobiscum - - . Tkinter . bordercolor , , , .

from Tkinter import *

root = Tk()
topframe = Frame(root, width = 300, height = 900)
topframe.pack()

frame = Frame(root, width = 202, height = 32, highlightbackground="black", highlightcolor="black", highlightthickness=1, bd=0)
l = Entry(frame, borderwidth=0, relief="flat", highlightcolor="white")
l.place(width=200, height=30)
frame.pack
frame.pack()
frame.place(x = 50, y = 30)

:

from Tkinter import *

def EntryBox(root_frame, w, h):
    boxframe = Frame(root_frame, width = w+2, height= h+2, highlightbackground="black", highlightcolor="black", highlightthickness=1, bd=0)
    l = Entry(boxframe, borderwidth=0, relief="flat", highlightcolor="white")
    l.place(width=w, height=h)
    l.pack()
    boxframe.pack()
    return boxframe

root = Tk()
frame = Frame(root, width = 1800, height = 1800)
frame.pack()

labels = []

for i in range(16):
    for j in range(16):
        box = EntryBox(frame, 40, 30)
        box.place(x = 50 + i*100, y = 30 + j*30 , width = 100, height = 30)
        labels.append(box)
0

Summary:

Lbl1 = Label(relief=GROOVE).pack()
0
source

Source: https://habr.com/ru/post/1654156/


All Articles