hbar config(command=text xviewcall text yview on scroll move or hbar['command']=text xview apply user configs or defaults startfont configs get('font'self fonts[ ]startbg configs get('bg'self colors[ ]['bg']startfg configs get('fg'self colors[ ]['fg']text config(font=startfontbg=startbgfg=startfgif 'heightin configstext config(height=configs['height']if 'widthin configstext config(width =configs['width']self text text self filelabel name ###########################################################################file menu commands ###########################################################################def my_askopenfilename(self)objects remember last result dir/file if not self opendialogself opendialog open(initialdir=self startfiledirfiletypes=self ftypesreturn self opendialog show(def my_asksaveasfilename(self)objects remember last result dir/file if not self savedialogself savedialog saveas(initialdir=self startfiledirfiletypes=self ftypesreturn self savedialog show(def onopen(selfloadfirst=''loadencode='')"" total rewrite for unicode supportopen in text mode with an encoding passed ininput from the userin textconfigor platform defaultor open as binary bytes for arbitrary unicode encodings as last resort and drop \ in windows end-lines if present so text displays normallycontent fetches are returned as strso need to encode on saveskeep encoding used heretests if file is okay ahead of time to try to avoid openswe could also load and manually decode bytes to str to avoid multiple open attemptsbut this is unlikely to try all casesencoding behavior is configurable in the local textconfig py tries known type first if passed in by client (email charsets if opensaskuser truetry user input next (prefill wih defaults if opensencoding nonemptytry this encoding next'latin- 'etc tries sys getdefaultencoding(platform default next uses binary mode bytes and tk policy as the last resort ""if self text_edit_modified() if not askyesno('pyedit''text has changeddiscard changes?')return pyedita text editor program/object