def openTCLFile(self): tf = filedialog.askopenfilename( initialdir=os.getcwd() + os.path.join("\\lab_tcl"), title="Choose TCL file", filetypes=(("TCL Files", "*.tcl"),) ) if tf == "": self.tclVar.set("") self.chooseTclLabel['text'] = "" return tf = open(tf) self.tclVar.set(tf.name) self.chooseTclLabel['text'] = tf.name[tf.name.rfind("/") + 1:len(tf.name)] tf.close()