class Label(Widget): """Label widget which can display text and bitmaps.""" def __init__(self, master=None, cnf={}, **kw): """Construct a label widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground, highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, takefocus, text, textvariable, underline, wraplength WIDGET-SPECIFIC OPTIONS height, state, width """ Widget.__init__(self, master, ‘label‘, cnf, kw)
from tkinter import * master = Tk() w = Label(master, text="Hello FishC!") w.pack() mainloop()
1.master --->Tk()实例化的对象
2.text= --->静态文本
3.front= --->字体
4.height
5.width
6.fg/bg --->前景色或者背景色
7.padx
8.pady
9.anchor ---> 文本或图像在背景内容区的位置,可选值为(n,s,w,e,ne,nw,sw,se,center)eswn是东南西北英文的首字母,表示:上北下南左西右东
10.underline = index--->目标文字的索引值
11.justify---> center(default) LEFT RIGHT
12.textvariable--->文本动态更新
1.lable可以自动跟新文本,在文本更新时,lable也会自动更新
2.lable用于在屏幕上显示文本或者图像,文本可以换行,但是字体只能是单一字体
原文:http://www.cnblogs.com/ezway/p/6438444.html