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