OpenFiles_7.py 709 B

12345678910111213141516171819202122
  1. def chooseVHDFiles(self):
  2. files = filedialog.askopenfilenames(
  3. initialdir=os.getcwd() + '\\testbenches\\',
  4. title="Choose VHD files",
  5. filetypes=(("VHD Files", "*.vhd"),)
  6. )
  7. labelText = ""
  8. self.selectedTestbenches = []
  9. try:
  10. for tf in files:
  11. if tf == "":
  12. self.tbUploadVar.set("")
  13. return
  14. tf = open(tf) # or tf = open(tf, 'r')
  15. self.selectedTestbenches.append(tf.name)
  16. labelText += tf.name[tf.name.rfind("/") + 1:len(tf.name)] + '\n'
  17. tf.close()
  18. except:
  19. self.tbSelectLabel['text'] = 'An Error Occured'
  20. return
  21. self.tbSelectLabel['text'] = labelText