def load(self, path=None): """ Load text from a path, or set text empty if no path. This method uses the default encoding for io.open, which may or may not make sense; a real, robust editor should use tokenize.open or equivalent to detect file encodings. Parameters ---------- path : path or '' or None The path of the file to load. If the path is None, use the path providied via self.obj. """ if path is None: path = self.obj if path: with open(path) as fp: self.code = fp.read() self.obj = path else: self.code = "" if self.ui is not None: # reset history self.ui.history = UndoHistory() self._last_save = 0
def create(self, parent): """ Create and set the toolkit-specific contents of the editor. """ super(PythonEditor, self).create(parent) self.ui.history = UndoHistory() self._last_save = 0