I need to set a white background color of the LabelFrame
title. I'm working on Tkinter in Python 3.6
-
1Hi, stackoverflow isn't a solution providing site. Kindly share what you have tried and where you stuck at, for better responses. To improve your chances for a better response kindly have a look at How do I ask a good question?– FortyTwoMar 14, 2019 at 14:34
1 Answer
You can specify your own widget to use as the LabelFrame
's "label" — this mean, for example, you could create a separate Label
widget with the text attributes you want, and specify it when creating the LabelFrame
via the labelwidget=
option:
import tkinter as tk
root = tk.Tk()
root.geometry('300x75')
label = tk.Label(root, text='Life, the universe and everything?', fg='white',
bg='blue')
lable_frame = tk.LabelFrame(root, labelwidget=label) # Use custom label.
lable_frame.pack(fill=tk.BOTH, expand=1, padx=5, pady=5)
w = tk.Entry(lable_frame)
w.pack(side=tk.LEFT, fill=tk.X, expand=1)
root.mainloop()
Result: