from tkinter import * import os def button_click1(): try: filePath = r‘D:\MyDocument\Programs\Python\oprate_file_system‘ #打开指定路径 os.system("explorer.exe %s"%filePath) app.destroy() except Exception as ex: print(ex) app = Tk() app.title("Your tkinter application") app.geometry(‘300x100+200+100‘) b1 = Button(app,text = "study place",width = 10,command = button_click1) b1.pack(side = ‘left‘,padx = 10,pady = 10) app.protocol("WM_DELETE_WINDOW",button_click1) #app.protocol("WM_SAVE_YOURSELF",button_click1) #app.protocol("WM_TAKE_FOCUS",button_click1) app.mainloop()
时间: 2024-10-24 20:30:43