创建标签
label = ttk.Label(parent, text='Full name:')
通过创建StringVar对象,可以将需要显示的文字内容设置为变量对象
label6 = ttk.Label(frame5)
txt = StringVar()
label6["textvariable"] = txt
txt.set("文字变量")
加入图片
创建PhotoImage对象,指定image属性为该对象。不能识别jpg格式,支持gif格式
label7 = ttk.Label(root)
image_p = PhotoImage(file="python.gif")
label7["image"] = image_p
需同时显示图片和文字时,需设定compound属性,可指定值为
image,text,center,top,left,right
label7 = ttk.Label(root)
image_p = PhotoImage(file="python.gif")
label7["image"] = image_p
label7["text"] = "PYTHON"
label7["compound"] = "left" # image,text,center,top
label = ttk.Label(parent, text='Full name:')
通过创建StringVar对象,可以将需要显示的文字内容设置为变量对象
label6 = ttk.Label(frame5)
txt = StringVar()
label6["textvariable"] = txt
txt.set("文字变量")
加入图片
创建PhotoImage对象,指定image属性为该对象。不能识别jpg格式,支持gif格式
label7 = ttk.Label(root)
image_p = PhotoImage(file="python.gif")
label7["image"] = image_p
需同时显示图片和文字时,需设定compound属性,可指定值为
image,text,center,top,left,right
label7 = ttk.Label(root)
image_p = PhotoImage(file="python.gif")
label7["image"] = image_p
label7["text"] = "PYTHON"
label7["compound"] = "left" # image,text,center,top