引用数据库:
from tkinter import *
root=Tk()
具体代码:
root.config(bg='#8DB6CD')
root.title("基于tk的图片文字")
root.geometry('600x600')
cv=Canvas (root, bg='white',width=500,height=500)
bitmaps =["error","gray75" ,"gray50","gray25","gray12",
"hourglass","info","questhead","question","warning"]
for i in range (len(bitmaps)):
cv.create_bitmap((i+1)*30,30,bitmap=bitmaps[i])
cv.create_text(30,60,text = "tkinter内置位图预览",fill='#7CCD7C',anchor = W,font=('微软雅黑',15,'bold'))
img = PhotoImage (file=r"此处引用你所选择的图片路径")
cv.create_image (30,220, image= img,anchor =W)
cv.create_text (30,350,text="图片预览",fill='#7CCD7C',anchor =W,font=('微软雅黑',15,'bold'))
cv.pack()
mainloop()
图片路径要一致。
运行结果: