zoukankan      html  css  js  c++  java
  • python tk Lable

    原文章

    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:

    1. master --->Tk()实例化的对象;父组件
    2. text= --->静态文本
    3. wraplength---> 将文本分成多行,可指定每行长度,unit是屏幕单元/默认0
    4. font= --->字体
    5. image---> 该值显示图片;应该是PhotoImage,BitmapImage或者能够兼容的对象,优先于text和bitmap
    6. height
    7. width---> 如果是文本,单位是文本单位,图像就是像素
    8. fg/bg --->前景色或者背景色
    9. padx
    10. pady
    11. anchor--->文本或图像在背景内容区的位置,可选值为(n,s,w,e,ne,nw,sw,se,center)eswn是东南西北英文的首字母,表示:上北下南左西右东
    12. underline = index--->目标文字的索引值
    13. justify---> center(default) LEFT RIGHT
    14. textvariable--->文本动态更新
    15. takefocus ---> 接受焦点输入;默认是False
    16. bitmap ---> 指定显示到lable上位图? 如果指定了image选项,则该选项被忽略
    17. borderwidth/bd --->边框宽度 默认有系统指定,通常是1 or 2像素
    18. relief---> 连框的样式;默认FLAT;可选SUNKED/RAISED/GROVE/RIDE
    19. state---> 指定lable状态;默认NORMAL;可选ACTIVE /DISABLE
    20. compound ---> 控制文本和图像的混合模式;默认有位图or图片不显示文本有CENTER/BOTTOM/ LEFT/ RIGHT /TOPBOTTOM图像在文本的下边;默认是NONE
    21. cursor---> 指定鼠标在lable上的鼠标样式;默认有系统指定
    22. disableforeground --->不可用的时候前景颜色
    23. highlightbackground ---> 没货的焦点的时候高亮边框颜色
    24. highlight---> 获得焦点的时候高亮边框

    Features

    1.lable可以自动跟新文本,在文本更新时,lable也会自动更新

    2.lable用于在屏幕上显示文本或者图像,文本可以换行,但是字体只能是单一字体

  • 相关阅读:
    electron 显示对话框 showMessageBoxSync showMessageBox
    c++ 随机数 取值范围 多线程
    c++ 字符串转换为数字
    VS2019 C++动态链接库的创建使用(1)
    js mutationobserver property vs attribute
    Chromium base 基础库概览
    Git:合并分支----git merge命令应用的三种情景
    chromium 处理 addEventListener 事件
    JavaScript监听属性改变
    chrome 启动开关参数
  • 原文地址:https://www.cnblogs.com/ezway/p/6438444.html
Copyright © 2011-2022 走看看