Python - 文件对话框
作者:互联网
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()
标签:文件,btn,tkinter,对话框,Python,text,b1,b2,main 来源: https://www.cnblogs.com/hgrun/p/python-filedialog.html