Author: bugman Date: Thu Sep 16 17:11:17 2010 New Revision: 11585 URL: http://svn.gna.org/viewcvs/relax?rev=11585&view=rev Log: The relax prompt GUI element now overrides the exiting functions 'exit', 'q', 'quit', 'bye'. These now correspond to the relax GUI exit_gui() method. The IO streams are also restored prior to printing out the citations, so they are printed in all cases. Modified: branches/bieri_gui/gui_bieri/relax_gui.py branches/bieri_gui/gui_bieri/relax_prompt.py branches/bieri_gui/relax_io.py Modified: branches/bieri_gui/gui_bieri/relax_gui.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/relax_gui.py?rev=11585&r1=11584&r2=11585&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/relax_gui.py (original) +++ branches/bieri_gui/gui_bieri/relax_gui.py Thu Sep 16 17:11:17 2010 @@ -31,6 +31,7 @@ import platform from re import search from string import lower, lowercase, replace +import sys from textwrap import wrap import time import webbrowser @@ -45,6 +46,7 @@ from generic_fns.mol_res_spin import generate_spin_id, spin_index_loop, spin_loop from generic_fns.reset import reset from relax_errors import RelaxError +from relax_io import io_streams_restore from version import version # relaxGUI module imports. @@ -129,7 +131,7 @@ self.controller = Controller(None, -1, "") # Build the relax prompt, but don't show it. - self.relax_prompt = Prompt(None, -1, "") + self.relax_prompt = Prompt(None, -1, "", parent=self) rx_data = ds.relax_gui.analyses[self.noe_index[0]] self.frame_1_statusbar = self.CreateStatusBar(3, 0) @@ -424,7 +426,7 @@ webbrowser.open_new('mailto:relax-users@xxxxxxx') - def exit_gui(self, event): + def exit_gui(self, event=None): """Catch the main window closure and perform the exit procedure. @param event: The wx event. @@ -436,6 +438,9 @@ # Exit. if doexit: + # Restore the IO streams. + io_streams_restore(verbosity=0) + # The relax information box. info = Info_box() @@ -457,7 +462,7 @@ for line in wrap(info.bib['dAuvergneGooley08b'].cite_short(), width): text = text + line + '\n' text = text + '\n' - print(text) + sys.__stdout__.write(text) # Destroy all dialogs. self.controller.Destroy() Modified: branches/bieri_gui/gui_bieri/relax_prompt.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/relax_prompt.py?rev=11585&r1=11584&r2=11585&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/relax_prompt.py (original) +++ branches/bieri_gui/gui_bieri/relax_prompt.py Thu Sep 16 17:11:17 2010 @@ -41,6 +41,9 @@ def __init__(self, *args, **kwds): """Set up the relax prompt.""" + # Store the parent object. + self.gui = kwds.pop('parent') + # Create GUI elements kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) @@ -79,6 +82,10 @@ self.prompt.StyleSetSpec(stc.STC_P_WORD, "fore:#a52a2a") self.prompt.StyleSetSpec(stc.STC_P_DEFNAME, "fore:#008b8b") self.prompt.StyleSetSpec(stc.STC_P_CLASSNAME, "fore:#008b8b") + + # Override the exiting commands. + for name in ['exit', 'bye', 'quit', 'q']: + self.prompt.interp.locals[name] = self.gui.exit_gui # Add the shell to the sizer. sizer.Add(self.prompt, 1, wx.EXPAND|wx.ALL, self.border) Modified: branches/bieri_gui/relax_io.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/relax_io.py?rev=11585&r1=11584&r2=11585&view=diff ============================================================================== --- branches/bieri_gui/relax_io.py (original) +++ branches/bieri_gui/relax_io.py Thu Sep 16 17:11:17 2010 @@ -204,8 +204,12 @@ return file_path -def io_streams_restore(): - """Restore all IO streams to the Python defaults.""" +def io_streams_restore(verbosity=1): + """Restore all IO streams to the Python defaults. + + @param verbosity: The verbosity level. + @type verbosity: int + """ # Print out. if verbosity: