Python GUI 实现功能

import tkinter as tk
import os

window = tk.Tk()
window.title("Check wendor files")
window.geometry('450x300')
# user information
tk.Label(window, text='Path: ').place(x=50, y=50)
var_path = tk.StringVar()
entry_path = tk.Entry(window, textvariable=var_path, width=40, show=None)
# var_path.set('please input  the path to check file')
print(entry_path.get())
entry_path.place(x=100, y=50)
path = r"D:\test"


# 遍历文件夹

def walkFile():
    usr_path = var_path.get()
    for root, dirs, files in os.walk(usr_path):

        # root 表示当前正在访问的文件夹路径
        # dirs 表示该文件夹下的子目录名list
        # files 表示该文件夹下的文件list
        # 遍历文件
        for f in files:
            var = os.path.join(root, f)
            print(var)
            t.insert("insert", var+"\n")

# walkFile(path)
btn_login = tk.Button(window, text='Start', width=10, command=walkFile)
btn_login.place(x=150, y=100)
t = tk.Text(window, height=13,width=50)
t.place(x=10, y=140)
window.mainloop()

你可能感兴趣的:(Python GUI 实现功能)