原文章
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()
Lable(master=None,**option) parameter:
master --->Tk()实例化的对象;父组件text= --->静态文本wraplength---> 将文本分成多行,可指定每行长度,unit是屏幕单元/默认0font= --->字体image---> 该值显示图片;应该是PhotoImage,BitmapImage或者能够兼容的对象,优先于text和bitmapheightwidth---> 如果是文本,单位是文本单位,图像就是像素fg/bg --->前景色或者背景色padxpadyanchor--->文本或图像在背景内容区的位置,可选值为(n,s,w,e,ne,nw,sw,se,center)eswn是东南西北英文的首字母,表示:上北下南左西右东underline = index--->目标文字的索引值justify---> center(default) LEFT RIGHTtextvariable--->文本动态更新takefocus ---> 接受焦点输入;默认是Falsebitmap ---> 指定显示到lable上位图? 如果指定了image选项,则该选项被忽略borderwidth/bd --->边框宽度 默认有系统指定,通常是1 or 2像素relief---> 连框的样式;默认FLAT;可选SUNKED/RAISED/GROVE/RIDEstate---> 指定lable状态;默认NORMAL;可选ACTIVE /DISABLEcompound ---> 控制文本和图像的混合模式;默认有位图or图片不显示文本有CENTER/BOTTOM/ LEFT/ RIGHT /TOPBOTTOM图像在文本的下边;默认是NONEcursor---> 指定鼠标在lable上的鼠标样式;默认有系统指定disableforeground --->不可用的时候前景颜色highlightbackground ---> 没货的焦点的时候高亮边框颜色highlight---> 获得焦点的时候高亮边框
Features
1.lable可以自动跟新文本,在文本更新时,lable也会自动更新
2.lable用于在屏幕上显示文本或者图像,文本可以换行,但是字体只能是单一字体
转载于:https://www.cnblogs.com/ezway/p/6438444.html