单击窗体按钮,实现打开文件夹

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() # 显示窗口 主事件循环
程序界面报错

如何实现点击 国际贸易 打开路径文件夹如何实现点击 国际贸易 打开路径文件夹

讨论数量: 1
Jason990420

Using lambda to provide extra arguments, like

button = Button(root, text="TRADE", font=('宋体', 15), fg='blue', command=lambda file_path=file_path:start_file(file_path))
2个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!