self filelabel config(text=str(name)def setknownencoding(selfencoding='utf- ') for saves if inserted self knownencoding encoding else saves use configaskdef setbg(selfcolor)self text config(bg=colordef setfg(selfcolor)self text config(fg=colordef setfont(selffont)self text config(font=fontdef setheight(selflines)self text config(height=linesdef setwidth(selfchars)self text config(width=charsdef clearmodified(self)self text edit_modified( def ismodified(self)return self text_edit_modified(to set manually from code 'black'hexstring ('family'size'style'default may also be from textcongif py clear modified flag changed since last resetdef help(self)showinfo('about pyedit'helptext ((version,)* )###############################################################################ready-to-use editor classes mixes in guimaker frame subclass which builds menu and toolbars these classes are common use casesbut other configurations are possiblecall texteditormain(mainloop(to start pyedit as standalone programredefine/extend onquit in subclass to catch exit or destroy (see pyview)caveatcould use windows py for iconsbut quit protocol is custom here ################################################################################ on quit()don' silently exit entire app if any other changed edit windows are open in the process changes would be lost because all other windows are closed tooincluding multiple tk editor parentsuses list to keep track of all pyedit window instances open in processthis may be too broad (if we destroy(instead of quit()need only check children of parent being destroyed)but better to err on side of being too inclusiveonquit moved here because varies per window type and is not present for allassumes texteditormainpopup is never parent to other editor windows toplevel children are destroyed with their parentsthis does not address closes outside the scope of pyedit classes here (tkinter quit is available on every widgetand any widget type may be toplevel parent!)client is responsible for checking for editor content changes in all uncovered casesnote that tkinter' bind event won' help herebecause its callback cannot run gui operations such as text change tests and fetches see the book and destroyer py for more details on this eventpyedita text editor program/object