python 打开文件对话框 filedialog tkinter GUI 编程

- -读取文件的gui编程

 1 # _*_ coding:utf-8 _*_
 2 
 3 import tkinter
 4 from tkinter import filedialog
 5 
 6 def openfiles2():
 7     s2fname = filedialog.askopenfilename(title='打开S2文件', filetypes=[('S2out', '*.out'), ('All Files', '*')])
 8     print(s2fname)
 9 def openfilecgns():
10     cgnsfname = filedialog.askopenfilename(title='打开CGNS文件',filetypes=[('CGNSdat', '*.dat'), ('All Files', '*')] )
11     print(cgnsfname)
12  
13 root = tkinter.Tk()
14 #root.geometry('500x300+500+200')
15 btn1 = tkinter.Button(root, text='打开S2文件',font =("宋体",20,'bold'),width=13,height=8, command=openfiles2)
16 btn2 = tkinter.Button(root, text='打开CGNS文件',font = ('宋体',20,'bold'),width=13,height=8, command=openfilecgns)
17  
18 btn1.pack(side='left')
19 btn2.pack(side='left')
20 root.mainloop()

- -

posted @ 2017-09-16 20:21  Anlovescode  阅读(16572)  评论(1编辑  收藏  举报