天下程序员首页cx06.com
管理 |  登录 |  注册
label组件添加文字与图片
更新于:2024-07-29

lable是基础组件之一:

lable能添加文字和图片

代码如下:

from tkinter import *
import sys
root=Tk()
root.title("第一个tk程序")
root.geometry("500x300+100+200")

label01=Label(root,text="天下程序员01",width=10,height=2,
              bg="black",fg="white")
label02=Label(root,text="天下程序员02",width=15,height=2,
              bg="black",fg="white",font=("黑体",30))
photo=PhotoImage(file=sys.path[0]+"/logo.png")
label03=Label(root,image=photo,width=190,height=200,
              bg="black",fg="white")

label01.pack()
label02.pack()
label03.pack()


root.mainloop()

效果如下:

天下程序员 www.cx06.com 程序员的网上家园!
作者微信:13126507001