utils_15.py 474 B

123456789101112131415
  1. def writefile(self, filename):
  2. self.fixlastline()
  3. chars = self.encode(self.text.get("1.0", "end-1c"))
  4. if self.eol_convention != "\n":
  5. chars = chars.replace("\n", self.eol_convention)
  6. try:
  7. f = open(filename, "wb")
  8. f.write(chars)
  9. f.flush()
  10. f.close()
  11. return True
  12. except IOError as msg:
  13. tkMessageBox.showerror("I/O Error", str(msg),
  14. master=self.text)
  15. return False