ext_filename.py
sver='title'
#Module import
import os, tkinter, tkinter.filedialog, tkinter.messagebox
#Display file selection dialog
root = tkinter.Tk()
root.withdraw()
#File format specification. The second argument"*txt"given that
#Only files with the extension txt are displayed.
fTyp = [("*","*")]
iDir = os.path.abspath(os.path.dirname(__file__))
res=tkinter.messagebox.askyesno(sver, 'Select input parameter file. \nSuspend the process if you choose "No"')
#Error message is displayed by selecting Cancel
if res==True:
file = tkinter.filedialog.askopenfilename(filetypes = fTyp,initialdir = iDir)
if file=='':
tkinter.messagebox.showerror(sver, "Suspend the process")
else:
#Output of processing file name
mess='Input file name is \n' + file
#Message in the box
tkinter.messagebox.showinfo(sver,mess)
else:
tkinter.messagebox.showerror(sver, "Suspend the process")
A screen like this is displayed ↓
Recommended Posts