思路:在一个画布上截取一部分图片作为文字的按钮或者Lable的背景,放在裁剪的画布相同位置。
from tkinter import *
from PIL import Image,ImageTk
root = Tk()
root.geometry('1024x410+0+0')
canvas = Canvas(width=800, height=500, highlightthickness=0, borderwidth=0)
canvas.place(x=0, y=0)
brick = PhotoImage(file='b.png')
bgid = canvas.create_image(0, 0, image=brick, anchor='nw')
btn = PhotoImage(file='b.png')
bgid = canvas.create_image(200,100, image=btn, anchor='nw')
txtid=canvas.create_text(370,140, font=("Purisa", 48),anchor="nw")
canvas.insert(txtid,1,"很好")
root.mainloop()