self st scrolledtext(selffile=fileattachnot subclass self st text config(font=('courier' 'normal')def onsave(self)filename asksaveasfilename(if filenamealltext self st gettext(open(filename' 'write(alltextgo through attribute def oncut(self)text self st text get(sel_firstsel_lastself st text delete(sel_firstsel_lastmore this code doesn' need to subclass frame necessarily (it could add widgets to the passedin parent directly)but being frame allows the full package here to be embedded and configured as well the window looks identical when such code is run 'll let you be the judge of whether composition or inheritance is better here if you code your python gui classes rightthey will work under either regime it' called "simplefor reasonpyedit (aheadfinallybefore you change your system registry to make simpleeditor your default text file vieweri should mention that although it shows the basicsit' something of stripped-down version (reallya prototypeof the pyedit example we'll meet in in factyou may wish to study that example now if you're looking for more complete tkinter text-processing code in general therewe'll also use more advanced text operationssuch as the undo/redo interfacecase-insensitive searchesexternal files searchand more because the text widget is so powerfulit' difficult to demonstrate more of its features without the volume of code that is already listed in the pyedit program should also point out that simpleeditor not only is limited in functionbut also is just plain careless--many boundary cases go unchecked and trigger uncaught exceptions that don' kill the guibut are not handled or reported well even errors that are caught are not reported to the user ( paste with nothing to be pastedbe sure to see the pyedit example for more robust and complete implementation of the operations introduced in simpleeditor unicode and the text widget told you earlier that text content in the text widget is always string technicallythoughthere are two string types in python xstr for unicode textand bytes for byte strings moreovertext can be represented in variety of unicode encodings when stored on files it turns out that both these factors can impact programs that wish to use text well in python tkinter tourpart