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
If you want a border, the option is borderwidth
. You can also choose the relief of the border: "flat"
, "raised"
, "sunken"
, "ridge"
, "solid"
, and "groove"
.
For example:
l1 = Label(root, text="This", borderwidth=2, relief="groove")
Note: "ridge"
and "groove"
require at least two pixels of width to render properly
@Pax Vobiscum - A way to do this is to take a widget and throw a frame with a color behind the widget. Tkinter for all its usefulness can be a bit primitive in its feature set. A bordercolor option would be logical for any widget toolkit, but there does not seem to be one.
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)
An example using this method, could be to create a table:
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)