def uploadZipFile(self): tf = filedialog.askopenfilename( initialdir=str(Path.home() / "Downloads"), title="Choose Zip file", filetypes=(("Zip Files", "*.zip"),) ) if tf == "": self.zipVar.set("") self.zipLabel['text'] = "" return tf = open(tf) # or tf = open(tf, 'r') self.zipVar.set(tf.name) self.zipLabel['text'] = tf.name[tf.name.rfind("/") + 1:len(tf.name)] tf.close()