Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2011 Edward d'Auvergne # 4 # # 5 # This file is part of the program relax (http://www.nmr-relax.com). # 6 # # 7 # This program 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 3 of the License, or # 10 # (at your option) any later version. # 11 # # 12 # This program 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 this program. If not, see <http://www.gnu.org/licenses/>. # 19 # # 20 ############################################################################### 21 22 # Module docstring. 23 """Module for handling errors in the GUI.""" 24 25 # Python module imports. 26 import sys 27 import wx 28 29 # relax module imports. 30 from status import Status; status = Status() 31 3234 """Handle errors in the GUI to be reported to the user. 35 36 @param relax_error: The error object. 37 @type relax_error: RelaxError instance 38 @keyword raise_flag: A flag which if True will cause the error to be raised, terminating execution. 39 @type raise_flag: bool 40 @raises RelaxError: This raises all RelaxErrors, if the raise flag is given. 41 """ 42 43 # Turn off the busy cursor if needed. 44 if wx.IsBusy(): 45 wx.EndBusyCursor() 46 47 # Non-fatal - the error is not raised so just send the text to STDERR, flushing the buffer to update the controller. 48 if not raise_flag: 49 sys.stderr.write(relax_error.__str__()) 50 sys.stderr.write("\n") 51 sys.stderr.flush() 52 53 # Show the relax controller (so that the window doesn't hide the dialog). 54 app = wx.GetApp() 55 app.gui.show_controller(None) 56 app.Yield(True) 57 58 # Show a dialog explaining the error. 59 dlg = wx.MessageDialog(None, relax_error.text, caption="RelaxError", style=wx.OK|wx.ICON_ERROR) 60 if status.show_gui: 61 dlg.ShowModal() 62 63 # Throw the error to terminate execution. 64 if raise_flag: 65 raise relax_error66
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 8 10:45:38 2024 | http://epydoc.sourceforge.net |