import tkinter as tk from tkinter import filedialog mywindow = tk.Tk() mywindow.title("添加一张矢量图") mycanvas = tk.Canvas(mywindow,width=450,height=350,bg="pink") mycanvas.pack() def myclick() : global img mya = filedialog.askopenfilename() img = tk.PhotoImage(file=mya) mypic = mycanvas.create_image(0,0,anchor="nw", image= img) mybu = tk.Button(mywindow,text="添加矢量图",command = myclick) mybu.pack(side=tk.BOTTOM,fill=tk.X)