--GUI programming for reading files
1 #_*_ coding:utf-8 _*_2 3 ImportTkinter4 fromTkinterImportFileDialog5 6 defopenfiles2 ():7S2fname = Filedialog.askopenfilename (title='Open S2 File', filetypes=[('S2out','*.out'), ('All Files','*')])8 Print(S2fname)9 defopenfilecgns ():TenCgnsfname = Filedialog.askopenfilename (title='Open cgns File', filetypes=[('Cgnsdat','*.dat'), ('All Files','*')] ) One Print(Cgnsfname) A -Root =Tkinter. Tk () - #root.geometry (' 500x300+500+200 ') theBTN1 = Tkinter. Button (Root, text='Open S2 File', Font = ("Song Body", 20,'Bold'), width=13,height=8, command=openfiles2) -BTN2 = Tkinter. Button (Root, text='Open cgns File', Font = ('Song Body', 20,'Bold'), width=13,height=8, command=openfilecgns) - -Btn1.pack (side=' Left') +Btn2.pack (side=' Left') -Root.mainloop ()
- -
Python Open File dialog box FileDialog tkinter GUI Programming