""add common edit tools to scrolledtext by inheritancecomposition (embeddingwould work just as well herethis is not robust!--see pyedit for feature superset""from tkinter import from tkinter simpledialog import askstring from tkinter filedialog import asksaveasfilename from quitter import quitter from scrolledtext import scrolledtext herenot python' class simpleeditor(scrolledtext)see pyedit for more def __init__(selfparent=nonefile=none)frm frame(parentfrm pack(fill=xbutton(frmtext='save'command=self onsavepack(side=leftbutton(frmtext='cut'command=self oncutpack(side=leftbutton(frmtext='paste'command=self onpastepack(side=leftbutton(frmtext='find'command=self onfindpack(side=leftquitter(frmpack(side=leftscrolledtext __init__(selfparentfile=fileself text config(font=('courier' 'normal')def onsave(self)filename asksaveasfilename(if filenamealltext self gettext(open(filename' 'write(alltextdef oncut(self)text self text get(sel_firstsel_lastself text delete(sel_firstsel_lastself clipboard_clear(self clipboard_append(textfirst through last store text in file error if no select should wrap in try def onpaste(self)add clipboard text trytext self selection_get(selection='clipboard'self text insert(inserttextexcept tclerrorpass not to be pasted def onfind(self)target askstring('simpleeditor''search string?'if targetwhere self text search(targetinsertendfrom insert cursor if wherereturns an index print(wherepastit where ('+%dclen(target)index past target #self text tag_remove(sel' 'endremove selection self text tag_add(selwherepastitselect found target self text mark_set(insertpastitset insert mark self text see(insertscroll display tkinter tourpart