def openmyfile(): try: import Tkinter, tkFileDialog try: root = Tkinter.Tk() filetoopen = tkFileDialog.Open(root, filetypes=[('plop files', '*.plop'),('All files', '*')]) sname = filetoopen.show() #root.mainloop() root.quit except Tkinter.TclError: sname = raw_input('Name of the system: ') except ImportError: sname = raw_input('Name of the system: ') return sname.strip()