OpenFiles_5.py 450 B

12345678910111213141516171819
  1. def openTCLFile(self):
  2. tf = filedialog.askopenfilename(
  3. initialdir=os.getcwd() + os.path.join("\\lab_tcl"),
  4. title="Choose TCL file",
  5. filetypes=(("TCL Files", "*.tcl"),)
  6. )
  7. if tf == "":
  8. self.tclVar.set("")
  9. self.chooseTclLabel['text'] = ""
  10. return
  11. tf = open(tf)
  12. self.tclVar.set(tf.name)
  13. self.chooseTclLabel['text'] = tf.name[tf.name.rfind("/") + 1:len(tf.name)]
  14. tf.close()