代码:
window = tk.Tk() window.title('文件上传') window.geometry('550x200') frm = tk.Frame(window) frm.grid(padx='20', pady='30') btn1 = tk.Button(frm, text='上传文件', font=('Arial', 12), width=10, height=1, command=upload_file) btn1.grid(row=0, column=0, ipadx='3', ipady='3', padx='10', pady='20') entry = tk.Entry(frm, width=40) entry.grid(row=0, column=1) def upload_file(): #指定上传mp4视频文件 # askopenfilename 1次上传1个;askopenfilenames1次上传多个 selectFile = tk.filedialog.askopenfilename(filetypes=(("MP4视频", "*.mp4"),)) entry.insert(0, selectFile)
实现效果:
标签:tkinter,指定,frm,window,grid,tk,entry,上传 From: https://www.cnblogs.com/yccy/p/16983544.html