单击窗体按钮,实现打开文件夹
from tkinter import *
import os
file_path = r’D:\VMware’ # 文件路径
def start_file(file_path):
os.startfile(file_path)
root = Tk() # 创建窗口:实例化一个窗口对象。
root.geometry(‘600x450’) # 窗口大小
root.title(‘贸易平台’) # 窗口标题
button = Button(root, text=”国际贸易”, font=(“宋体”, 15), fg=”blue”, command=start_file)
button.grid(row=10, column=1)
root.mainloop() # 显示窗口 主事件循环
Using
lambda
to provide extra arguments, like