Package gui :: Package user_functions :: Module relax_fit
[hide private]
[frames] | no frames]

Source Code for Module gui.user_functions.relax_fit

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2010-2011 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  """The relaxation data user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  from string import split 
 28   
 29  # relax module imports. 
 30  from generic_fns import pipes 
 31   
 32  # GUI module imports. 
 33  from base import UF_base, UF_page 
 34  from gui.paths import WIZARD_IMAGE_PATH 
 35  from gui.misc import gui_to_float, gui_to_int, gui_to_str, str_to_gui 
 36   
 37   
 38  # The container class. 
39 -class Relax_fit(UF_base):
40 """The container class for holding all GUI elements.""" 41
42 - def relax_time(self):
43 """The relax_fit.relax_time user function.""" 44 45 # Execute the wizard. 46 wizard = self.create_wizard(size_x=800, size_y=600, name='relax_fit.relax_time', uf_page=Relax_time_page) 47 wizard.run()
48 49
50 - def select_model(self):
51 """The relax_fit.select_model user function.""" 52 53 # Execute the wizard. 54 wizard = self.create_wizard(size_x=800, size_y=600, name='relax_fit.select_model', uf_page=Select_model_page) 55 wizard.run()
56 57 58
59 -class Relax_time_page(UF_page):
60 """The relax_fit.relax_time() user function page.""" 61 62 # Some class variables. 63 uf_path = ['relax_fit', 'relax_time'] 64
65 - def add_contents(self, sizer):
66 """Add the specific GUI elements. 67 68 @param sizer: A sizer object. 69 @type sizer: wx.Sizer instance 70 """ 71 72 # The time. 73 self.time = self.input_field(sizer, "The delay time:", tooltip=self.uf._doc_args_dict['time']) 74 75 # The spectrum ID. 76 self.spectrum_id = self.combo_box(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id']) 77 78 # Spacing. 79 sizer.AddStretchSpacer()
80 81
82 - def on_execute(self):
83 """Execute the user function.""" 84 85 # The time. 86 time = gui_to_float(self.time.GetValue()) 87 88 # The spectrum ID. 89 spectrum_id = gui_to_str(self.spectrum_id.GetValue()) 90 91 # Read the relaxation data. 92 self.execute('relax_fit.relax_time', time=time, spectrum_id=spectrum_id)
93 94
95 - def on_display(self):
96 """Clear previous data and update the spectrum ID list.""" 97 98 # Clear the previous data. 99 self.spectrum_id.Clear() 100 101 # No data, so don't try to fill the combo box. 102 if not hasattr(cdp, 'spectrum_ids'): 103 return 104 105 # The spectrum IDs. 106 for i in range(len(cdp.spectrum_ids)): 107 self.spectrum_id.Append(str_to_gui(cdp.spectrum_ids[i]))
108 109 110
111 -class Select_model_page(UF_page):
112 """The relax_fit.select_model() user function page.""" 113 114 # Some class variables. 115 uf_path = ['relax_fit', 'select_model'] 116
117 - def add_contents(self, sizer):
118 """Add the specific GUI elements. 119 120 @param sizer: A sizer object. 121 @type sizer: wx.Sizer instance 122 """ 123 124 # The model. 125 self.model = self.combo_box(sizer, "The model:", choices=['exp', 'inv'], tooltip=self.uf._doc_args_dict['model']) 126 self.model.SetValue(str_to_gui('exp')) 127 128 # Spacing. 129 sizer.AddStretchSpacer()
130 131
132 - def on_execute(self):
133 """Execute the user function.""" 134 135 # The model. 136 model = gui_to_str(self.model.GetValue()) 137 138 # Read the relaxation data. 139 self.execute('relax_fit.select_model', model=model)
140