首页 > 其他 > 详细

tkinter label第二节

时间:2017-09-23 15:57:53      阅读:342      评论:0      收藏:0      [点我收藏+]
from tkinter import *
from tkinter import ttk

root=Tk()
label=ttk.Label(root,text="abc") #之前随便写一个label为abc
label.pack() #一定要,没有就不显示
label.config(text="i am very confusing, i want make a lot ofmoney,but it seems not true ") #通过label.config来修改label标签中的text值
label.config(wraplength=100)# 这个字的宽度被限制了 Determines when a label’s text should be wrapped into multiple lines. This is given in screen units. Default is 0 (no wrapping). (wrapLength/WrapLength 默认是像素
                 #https://stackoverflow.com/questions/41773962/python-gui-what-are-screen-units-in-tkinter 参考这个
label.config(justify=CENTER) #调整字的位置到中间
label.config(foreground=‘blue‘,background="yellow")#字体本身设置成蓝色。背景设置成黄色
label.config(font=(‘Courier‘,18,‘bold‘)) #设置字体
label.config(text="Howdy, Tkinter!") #再次改变字体
logo=PhotoImage(file=r‘C:\Users\koyaku\PycharmProjects\2017\30day\ohyeah.gif‘) #导入图片。记住python 默认只能识别png gif字体。要用jpeg 需要PIL模块
label.config(image=logo) #导入
label.config(compound=‘text‘)#设置字显示
label.config(compound=‘center‘)#字显示在中间
#label.config(compound=‘left‘)#

root.mainloop()

技术分享

 

tkinter label第二节

原文:http://www.cnblogs.com/uxiuxi/p/7581348.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!