123456789101112131415161718192021222324252627282930313233343536373839 |
- def uploadVHDFile(self):
- files = filedialog.askopenfilenames(
- initialdir=os.getcwd(),
- title="Choose VHD files",
- filetypes=(("VHD Files", "*.vhd"),)
- )
- try:
- for tf in files:
- if tf == "":
- self.tbUploadVar.set("")
- return
- tf = open(tf) # or tf = open(tf, 'r')
- filename = tf.name[tf.name.rfind("/") + 1:len(tf.name)]
- # copy file over to tcl locations
- if filename.endswith("true_testbench.vhd"):
- shutil.copy(tf.name, os.getcwd() + os.path.join("\\testbenches"))
- else:
- shutil.copy(tf.name, os.getcwd() + os.path.join(f'''\\testbenches\\{filename[0:len(filename)-4]}_true_testbench.vhd''' ))
- tf.close()
- except:
- self.tbUploadLabel.configure(style="Red.TLabel")
- self.tbUploadVar.set("An Error Occurred")
- return
- if len(files) == 1:
- # Generate an animation for the result
- self.tbUploadLabel.configure(style="Green.TLabel")
- self.tbUploadVar.set("Copied " + files[0][files[0].rfind("/") + 1:len(files[0])])
- elif len(files) > 1:
- self.tbUploadLabel.configure(style="Green.TLabel")
- self.tbUploadVar.set("Copied " + str(len(files)) + " Files")
- elif len(files) == 0:
- self.tbUploadLabel.configure(style="TLabel")
- self.tbUploadVar.set("")
|