打开文件对话框,,from tkinter
文章由Byrx.net分享于2019-03-23 09:03:56
打开文件对话框,,from tkinter
from tkinter import *from tkinter.filedialog import askopenfilenamefrom tkinter.messagebox import showerrorclass MyFrame(Frame): def __init__(self): Frame.__init__(self) self.master.title("Example") self.master.rowconfigure(5, weight=1) self.master.columnconfigure(5, weight=1) self.grid(sticky=W+E+N+S) self.button = Button(self, text="Browse", command=self.load_file, width=10) self.button.grid(row=1, column=0, sticky=W) def load_file(self): fname = askopenfilename(filetypes=(("Template files", "*.tplate"), ("HTML files", "*.html;*.htm"), ("All files", "*.*") )) if fname: try: print("""here it comes: self.settings["template"].set(fname)""") except: # <- naked except is a bad idea showerror("Open Source File", "Failed to read file\\n'%s'" % fname) returnif __name__ == "__main__": MyFrame().mainloop()#该片段来自于http://byrx.net
相关内容
- Session for Tornado(Redis),tornadoredis,session id的生
- 使用python登录人人网并发表状态,python登录人人发表
- 使用Python解决FizzBuzz问题,python解决fizzbuzz,FizzBuzz问题描
- 文件夹对比,,买了个移动硬盘备份 但是
- 简单模拟编译前端过程,简单模拟编译过程,学了几天
- 文本文件常用工具,,common_lib/u
- 模拟登录人人网,模拟登录人人,from seleniu
- UPS电源下,自动关机,UPS电源,自动关机,停电后,在U
- 获取页面url,页面url,import reimp
- 批量文件重命名,,import sysim
评论关闭