0

I need to set a white background color of the LabelFrame title. I'm working on Tkinter in Python 3.6

Capture

1
  • 1
    Hi, 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?
    – FortyTwo
    Mar 14, 2019 at 14:34

1 Answer 1

2

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:

screenshot

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.