Author: bugman Date: Fri Feb 5 11:59:10 2010 New Revision: 10664 URL: http://svn.gna.org/viewcvs/relax?rev=10664&view=rev Log: Clean up and expansion of the question() dialog box showing method. A docstring and comments have been added. And the arg default added to allow yes or no to be the default button. Modified: branches/bieri_gui/gui_bieri/message.py Modified: branches/bieri_gui/gui_bieri/message.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/message.py?rev=10664&r1=10663&r2=10664&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/message.py (original) +++ branches/bieri_gui/gui_bieri/message.py Fri Feb 5 11:59:10 2010 @@ -58,14 +58,30 @@ wx.MessageBox('Missing Data!', style = wx.OK | wx.ICON_ERROR) -def question(msg): - check = False - startrelax = wx.MessageDialog(None, message = msg, style = wx.YES_NO | wx.NO_DEFAULT) - if startrelax.ShowModal() == wx.ID_YES: - check = True +def question(msg, default=False): + """A generic question box. + + @keyword default: If True, the default button will be 'yes', otherwise it will be 'no'. + @type default: bool + @return: The answer. + @rtype: bool + """ + + # If default. + if default: + style = wx.YES_DEFAULT else: - check = False - return check + style = wx.NO_DEFAULT + + # The dialog window. + dialog = wx.MessageDialog(None, message = msg, style = wx.YES_NO | style) + + answer = False + if dialog.ShowModal() == wx.ID_YES: + answer = True + + # Return the answer. + return answer def relax_run_ok(msg1):