python 实现设置tkinter的背景图片

  • Post author:
  • Post category:python


import tkinter as tk

root = tk.Tk()
root.geometry("1200x500")  # 设置窗口大小

canvas = tk.Canvas(root, width=1100, height=500)
canvas.pack()

img = tk.PhotoImage(file=r"C:\Users\Thinkpad\Desktop\大坝安全监测数据处理程序\水库大坝安全监测图.png")
canvas.create_image(0, 0, anchor="nw", image=img)

root.mainloop()



版权声明:本文为ducanwang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。