def uploadTextFile(self): files = filedialog.askopenfilenames( initialdir=os.getcwd(), title="Choose Text files", filetypes=(("Text Files", "*.txt"),) ) try: for tf in files: if tf == "": self.textUploadVar.set("") return tf = open(tf) # or tf = open(tf, 'r') # copy file over to tcl locations shutil.copy(tf.name, os.getcwd() + os.path.join("\\studentlists")) tf.close() except: self.studentListLabel.configure(style="Red.TLabel") self.textUploadVar.set("An Error Occurred") return if len(files) == 1: # Generate an animation for the result self.studentListLabel.configure(style="Green.TLabel") self.textUploadVar.set("Copied " + files[0][files[0].rfind("/") + 1:len(files[0])]) elif len(files) > 1: self.studentListLabel.configure(style="Green.TLabel") self.textUploadVar.set("Copied " + str(len(files)) + " Files") elif len(files) == 0: self.studentListLabel.configure(style="TLabel") self.textUploadVar.set("")