import tkinter
import tkinter.filedialog
def btn_click():
global p
c = tkinter.filedialog.askopenfilename(filetypes=[("PNG",".png")])
p = tkinter.PhotoImage(file=c)
b2.config(image=p)
main = tkinter.Tk()
main.geometry('800x600')
b1 = tkinter.Button(main, text='Open')
b1.config(command=btn_click)
b1.pack()
b2 = tkinter.Button(main, text='...')
b2.pack()
原创文章,作者:,如若转载,请注明出处:https://blog.ytso.com/272815.html