1.创建
from tkinter import *
root=Tk()
for fm in ['red','blue','yellow','green','white','black']:
Frame(height=20,width=400,bg=fm).pack()
root.mainloop()
2.添加控件
from tkinter import *
root=Tk()
fm=[]
for color in ['red','blue','yellow','green','white','black']:
fm.append(Frame(height=20,width=400,bg=color))
Label(fm[1],text='Hello label').pack()
fm[0].pack()
fm[1].pack()
root.mainloop()
3.LabelFrame添加Title支持
from tkinter import *
root=Tk()
fm=[]
for color in ['red','blue','yellow','green','white','black']:
LabelFrame(height=20,width=400,bg=color,text=color).pack()
root.mainloop()