python内置GUI库tkinter——Label类属性

 

From tkinter import *

Root=Tk()

Label1=Label(root,                    #标签控件添加到root窗口中

                      Width=10             #宽

                      Height=10            #高

                      text=”标签内容”     #标签的显示文字”,

                      Wraplength=80        #指定多少单位后开始换行

                      Justify=”left”            #指定多行的对齐方式

                      Ahchor=”e”            #指定文本(text)或图像(bitmap/image)在Label中的显示位置,所取值:e、w、n、s、ne、se、sw、sn、center ; 结果布局:

                                                     

                     bg=”red”                 #背景颜色  

                     fg=”#FF00FF”        #字体颜色 

                                                  

                    bitmap='error'       #内置位图—可用的位图:   * error * hourglass * info * questhead* question* warning

                                                 自定义位图: bitmap="@/path/bitmapname"

           

                    Compound=”left”     #同时使用图形文本时候,定义图形和文本的位置关系,

                                                     其值有:left:图像居左 right:图像居右top:图像居上bottom:图像居下center:

                                                     文字覆盖在图像上 若不设置compound则文字被图像自动覆盖

 

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

posted on 2018-02-07 14:56  群二  阅读(513)  评论(0编辑  收藏  举报

导航