inherits quit and other behavior of the window that it clones subclass must redefine/replace this if makes its own popupelse this creates bogus extra window here which will be empty""if not makewindownew none assume class makes its own window elsenew toplevel( new edit window in same process myclass self __class__ instance' (lowestclass object myclass(newattach/run instance of my class def onruncode(selfparallelmode=true)""run python code being edited--not an idebut handytries to run in file' dirnot cwd (may be pp root)inputs and adds command-line arguments for script filescode' stdin/out/err editor' start windowif anyrun with console window to see code' print outputsbut parallelmode uses start to open dos box for /omodule search path will include dir where startedin non-file modecode' tk root may be pyedit' windowsubprocess or multiprocessing modules may work here too fixed to use base file name after chdirnot path use startargs to allow args in file mode on windows run an update(after st dialog else nd dialog sometimes does not appear in rare cases""def askcmdargs()return askstring('pyedit''commandline arguments?'or 'from pp launchmodes import systemstartstartargsfork filemode false thefile str(self getfilename()if os path exists(thefile)filemode askyesno('pyedit''run from file?'self update( run update(if not filemoderun text string cmdargs askcmdargs(namespace {'__name__''__main__'run as top-level sys argv [thefilecmdargs split(could use threads exec(self getalltext('\ 'namespaceexceptions ignored elif self text_edit_modified() changed test showerror('pyedit''text changedyou must save before run'elsecmdargs askcmdargs(mycwd os getcwd(cwd may be root dirnamefilename os path split(thefileget dirbase os chdir(dirname or mycwdcd for filenames thecmd filename cmdargs not thefile if not parallelmoderun as file system(thecmdthecmd)(block editor elsepyedita text editor program/object