[英]Tkinter. How to change the background color of LabelFrame title?
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: 您可以指定自己的窗口小部件用作
LabelFrame
的“标签”,例如,这意味着您可以使用所需的文本属性创建一个单独的Label
小部件,并在通过labelwidget=
选项创建LabelFrame
时指定它:
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: 结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.