1234567891011121314151617181920212223242526272829303132 |
- def uploadTCLFile(self):
- files = filedialog.askopenfilenames(
- initialdir=os.getcwd(),
- title="Choose TCL files",
- filetypes=(("TCL Files", "*.tcl"),)
- )
- try:
- for tf in files:
- if tf == "":
- self.tclUploadVar.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("\\lab_tcl"))
- tf.close()
- except:
- self.tclStatusLabel.configure(style="Red.TLabel")
- self.tclUploadVar.set("An Error Occurred")
- return
- if len(files) == 1:
- # Generate an animation for the result
- self.tclStatusLabel.configure(style="Green.TLabel")
- self.tclUploadVar.set("Copied " + files[0][files[0].rfind("/") + 1:len(files[0])])
- elif len(files) > 1:
- self.tclStatusLabel.configure(style="Green.TLabel")
- self.tclUploadVar.set("Copied " + str(len(files)) + " Files")
- elif len(files) == 0:
- self.tclStatusLabel.configure(style="TLabel")
- self.tclUploadVar.set("")
|