def save(evt, designer):
<EOL>ok = gui.confirm("<STR_LIT>", "<STR_LIT>", <EOL>cancel=True, default=True)<EOL>if ok:<EOL><INDENT>wx_obj = evt.GetEventObject()<EOL>w = wx_obj.obj<EOL>try:<EOL><INDENT>if DEBUG: print("<STR_LIT>")<EOL>fin = open(designer.filename, "<STR_LIT:r>")<EOL>fout = open(designer.filename + "<STR_LIT>", "<STR_LIT:w>")<EOL>fout.write(fin.read())<EOL>fout.close()<EOL>fin.close()<EOL>if designer.filename.endswith("<STR_LIT>"):<EOL><INDENT>gui.save(designer.filename, [gui.dump(w)])<EOL><DEDENT>else:<EOL><INDENT>fin = open(designer.filename + "<STR_LIT>", "<STR_LIT:r>")<EOL>fout = open(designer.filename, "<STR_LIT:w>")<EOL>copy = True<EOL>newlines = fin.newlines or "<STR_LIT:\n>"<EOL>def dump(obj, indent=<NUM_LIT:1>):<EOL><INDENT>"<STR_LIT>"<EOL>for ctl in obj[:]:<EOL><INDENT>write(ctl, indent)<EOL><DEDENT><DEDENT>def write(ctl, indent):<EOL><INDENT>if ctl[:]:<EOL><INDENT>fout.write("<STR_LIT:U+0020>" * indent * <NUM_LIT:4>)<EOL>fout.write("<STR_LIT>" % ctl.__repr__(parent=None, indent=indent, context=True))<EOL>fout.write(newlines)<EOL>dump(ctl, indent + <NUM_LIT:1>)                <EOL><DEDENT>else:<EOL><INDENT>fout.write("<STR_LIT:U+0020>" * indent * <NUM_LIT:4>)<EOL>fout.write(ctl.__repr__(parent=None, indent=indent))<EOL>fout.write(newlines)<EOL><DEDENT><DEDENT>dumped = False<EOL>for line in fin:<EOL><INDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>fout.write(line)<EOL>fout.write(newlines)<EOL>write(w, indent=<NUM_LIT:0>)<EOL>fout.write(newlines)<EOL>dumped = True<EOL>copy = False<EOL><DEDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>copy = True<EOL><DEDENT>if copy:<EOL><INDENT>fout.write(line)<EOL><DEDENT><DEDENT>if not dumped:<EOL><INDENT>gui.alert("<STR_LIT>"<EOL>"<STR_LIT>", <EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>fout.close()<EOL>fin.close()<EOL><DEDENT>except Exception as e:<EOL><INDENT>import traceback<EOL>print((traceback.print_exc()))<EOL>ok = gui.confirm("<STR_LIT>" % str(e), '<STR_LIT>', <EOL>ok=True, cancel=True)<EOL><DEDENT><DEDENT>if ok is not None:<EOL><INDENT>wx.CallAfter(exit)    <EOL><DEDENT>return ok                 <EOL>
Basic save functionality: just replaces the gui code