mailr11586 - /branches/bieri_gui/gui_bieri/relax_prompt.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on September 16, 2010 - 17:21:
Author: bugman
Date: Thu Sep 16 17:21:25 2010
New Revision: 11586

URL: http://svn.gna.org/viewcvs/relax?rev=11586&view=rev
Log:
Created the _Exit class so that the prompt GUI element exit fns behave the 
same as in prompt mode.


Modified:
    branches/bieri_gui/gui_bieri/relax_prompt.py

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=11586&r1=11585&r2=11586&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/relax_prompt.py (original)
+++ branches/bieri_gui/gui_bieri/relax_prompt.py Thu Sep 16 17:21:25 2010
@@ -85,7 +85,7 @@
 
         # Override the exiting commands.
         for name in ['exit', 'bye', 'quit', 'q']:
-            self.prompt.interp.locals[name] = self.gui.exit_gui
+            self.prompt.interp.locals[name] = _Exit(fn=self.gui.exit_gui)
 
         # Add the shell to the sizer.
         sizer.Add(self.prompt, 1, wx.EXPAND|wx.ALL, self.border)
@@ -126,6 +126,28 @@
         return sizer
 
 
+class _Exit:
+    def __init__(self, fn=None):
+        """Store the exiting function.
+
+        @keyword fn:    The exiting function.
+        @type fn:       func
+        """
+
+        # Store.
+        self.fn = fn
+
+
+    def __repr__(self):
+        """Exit the program."""
+
+        # Execute the exiting function.
+        self.fn()
+
+        # Return nothing.
+        return ''
+
+
 class InterpClass(wx.py.interpreter.Interpreter):
     def __init__(self, locals=None, rawin=None, stdin=sys.stdin, 
stdout=sys.stdout, stderr=sys.stderr, showInterpIntro=True):
         """Redefine the interpreter."""




Related Messages


Powered by MHonArc, Updated Thu Sep 16 18:40:02 2010