Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2011-2012 Edward d'Auvergne # 4 # # 5 # This file is part of the program relax. # 6 # # 7 # relax is free software; you can redistribute it and/or modify # 8 # it under the terms of the GNU General Public License as published by # 9 # the Free Software Foundation; either version 2 of the License, or # 10 # (at your option) any later version. # 11 # # 12 # relax is distributed in the hope that it will be useful, # 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 # GNU General Public License for more details. # 16 # # 17 # You should have received a copy of the GNU General Public License # 18 # along with relax; if not, write to the Free Software # 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 20 # # 21 ############################################################################### 22 23 # Module docstring. 24 """Module for handling errors in the GUI.""" 25 26 # Python module imports. 27 import sys 28 import wx 29 30 # relax module imports. 31 from status import Status; status = Status() 32 3335 """Handle errors in the GUI to be reported to the user. 36 37 @param relax_error: The error object. 38 @type relax_error: RelaxError instance 39 @keyword raise_flag: A flag which if True will cause the error to be raised, terminating execution. 40 @type raise_flag: bool 41 @raises RelaxError: This raises all RelaxErrors, if the raise flag is given. 42 """ 43 44 # Die if running in test mode. 45 if status.test_mode: 46 raise relax_error 47 48 # Turn off the busy cursor if needed. 49 if wx.IsBusy(): 50 wx.EndBusyCursor() 51 52 # Non-fatal - the error is not raised so just send the text to STDERR. 53 if not raise_flag: 54 sys.stderr.write(relax_error.__str__()) 55 sys.stderr.write("\n") 56 57 # Show the relax controller (so that the window doesn't hide the dialog). 58 app = wx.GetApp() 59 app.gui.show_controller(None) 60 app.Yield(True) 61 62 # Show a dialog explaining the error. 63 dlg = wx.MessageDialog(None, relax_error.text, caption="RelaxError", style=wx.OK|wx.ICON_ERROR) 64 if status.show_gui: 65 dlg.ShowModal() 66 67 # Throw the error to terminate execution. 68 if raise_flag: 69 raise relax_error70
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Apr 10 14:17:10 2013 | http://epydoc.sourceforge.net |