mailr13691 - /branches/gui_testing/gui/message.py


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

Header


Content

Posted by edward on July 18, 2011 - 14:51:
Author: bugman
Date: Mon Jul 18 14:51:08 2011
New Revision: 13691

URL: http://svn.gna.org/viewcvs/relax?rev=13691&view=rev
Log:
The message boxes in the message module are now only shown if status.show_gui 
is set.

If not, the error or message is written to sys.stderr.


Modified:
    branches/gui_testing/gui/message.py

Modified: branches/gui_testing/gui/message.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/message.py?rev=13691&r1=13690&r2=13691&view=diff
==============================================================================
--- branches/gui_testing/gui/message.py (original)
+++ branches/gui_testing/gui/message.py Mon Jul 18 14:51:08 2011
@@ -1,7 +1,7 @@
 
###############################################################################
 #                                                                            
 #
 # Copyright (C) 2009 Michael Bieri                                           
 #
-# Copyright (C) 2010 Edward d'Auvergne                                       
 #
+# Copyright (C) 2010-2011 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax.                                    
 #
 #                                                                            
 #
@@ -23,7 +23,11 @@
 
 # Python module imports
 from os import sep
+import sys
 import wx
+
+# relax module imports.
+from status import Status; status = Status()
 
 # relax GUI module imports.
 from paths import IMAGE_PATH
@@ -41,7 +45,18 @@
     """
 
     # Show the message box.
-    wx.MessageBox(msg, caption=caption, style=wx.OK|wx.ICON_ERROR)
+    if status.show_gui:
+        wx.MessageBox(msg, caption=caption, style=wx.OK|wx.ICON_ERROR)
+
+
+    # Otherwise throw the error out to stderr.
+    else:
+        # Combine the caption and message.
+        if caption:
+            msg = "%s:  %s" % (caption, msg)
+
+        # Write out.
+        sys.stderr.write(msg + "\n")
 
 
 def exec_relax():
@@ -71,7 +86,12 @@
         msg = msg + "    %s\n" % data
 
     # The GUI element.
-    wx.MessageBox(msg, caption='Missing data', style=wx.OK|wx.ICON_ERROR)
+    if status.show_gui:
+        wx.MessageBox(msg, caption='Missing data', style=wx.OK|wx.ICON_ERROR)
+
+    # Otherwise throw the error out to stderr.
+    else:
+        sys.stderr.write("Missing data:  %s\n" % msg)
 
 
 def question(msg, default=False):
@@ -101,7 +121,11 @@
 
 
 def relax_run_ok(msg1):
-    wx.MessageBox(msg1, style = wx.OK)
+    """Message box stating that the relax run completed ok."""
+
+    # Show the message box.
+    if status.show_gui:
+        wx.MessageBox(msg1, style = wx.OK)
 
 
 




Related Messages


Powered by MHonArc, Updated Mon Jul 18 15:00:01 2011