1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23   
 24  """The value user function GUI elements.""" 
 25   
 26   
 27  import wx 
 28   
 29   
 30  from relax_errors import RelaxImplementError, RelaxNoPipeError 
 31  import specific_fns 
 32   
 33   
 34  from base import UF_base, UF_page 
 35  from gui.errors import gui_raise 
 36  from gui.misc import gui_to_bool, gui_to_str, str_to_gui 
 37  from gui.paths import WIZARD_IMAGE_PATH 
 38   
 39   
 40   
 42      """The container class for holding all GUI elements.""" 
 43   
 44 -    def view(self, file=None): 
  60   
 61   
 62 -    def write(self, file=None): 
   78   
 79   
 80   
 81 -class View_page(UF_page): 
  82      """The grace.view() user function page.""" 
 83   
 84       
 85      image_path = WIZARD_IMAGE_PATH + 'grace.png' 
 86      uf_path = ['grace', 'view'] 
 87   
 88 -    def add_contents(self, sizer): 
  89          """Add the specific GUI elements. 
 90   
 91          @param sizer:   A sizer object. 
 92          @type sizer:    wx.Sizer instance 
 93          """ 
 94   
 95           
 96          self.file = self.file_selection(sizer, "The Grace file:", message="Grace file selection", wildcard="Grace files (*.agr)|*.agr", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file']) 
 97   
 98           
 99          self.grace_exe = self.file_selection(sizer, "The Grace executable:", message="Grace executable file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['grace_exe']) 
100          self.grace_exe.SetValue(str_to_gui('xmgrace')) 
 101   
102   
103 -    def on_execute(self): 
 104          """Execute the user function.""" 
105   
106           
107          file = gui_to_str(self.file.GetValue()) 
108   
109           
110          grace_exe = gui_to_str(self.grace_exe.GetValue()) 
111   
112           
113          self.execute('grace.view', file=file, dir=None, grace_exe=grace_exe) 
  114   
115   
116   
117 -class Write_page(UF_page): 
 118      """The grace.write() user function page.""" 
119   
120       
121      image_path = WIZARD_IMAGE_PATH + 'grace.png' 
122      uf_path = ['grace', 'write'] 
123   
124 -    def add_contents(self, sizer): 
 125          """Add the specific GUI elements. 
126   
127          @param sizer:   A sizer object. 
128          @type sizer:    wx.Sizer instance 
129          """ 
130   
131           
132          self.x_data_type = self.combo_box(sizer, "The X-axis data type:", tooltip=self.uf._doc_args_dict['x_data_type']) 
133          self.update_parameters(self.x_data_type) 
134   
135           
136          if self.setup_fail: 
137              return 
138   
139           
140          self.y_data_type = self.combo_box(sizer, "The Y-axis data type:", tooltip=self.uf._doc_args_dict['y_data_type']) 
141          self.update_parameters(self.y_data_type) 
142   
143           
144          self.spin_id = self.spin_id_element(sizer, "Restrict plotting to certain spins:") 
145   
146           
147          self.plot_data = self.combo_box(sizer, "The plot data:", ['value', 'error', 'sims'], tooltip=self.uf._doc_args_dict['plot_data'], read_only=True) 
148          self.plot_data.SetValue(str_to_gui('value')) 
149   
150           
151          self.norm = self.boolean_selector(sizer, "Data normalisation flag:", tooltip=self.uf._doc_args_dict['norm'], default=False) 
152   
153           
154          self.file = self.file_selection(sizer, "The Grace file:", message="Grace file selection", wildcard="Grace files (*.agr)|*.agr", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 
155   
156           
157          self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force']) 
 158   
159   
160 -    def on_execute(self): 
 161          """Execute the user function.""" 
162   
163           
164          x_data_type = self.x_data_type.GetClientData(self.x_data_type.GetSelection()) 
165          y_data_type = self.y_data_type.GetClientData(self.y_data_type.GetSelection()) 
166   
167           
168          spin_id =   gui_to_str(self.spin_id.GetValue()) 
169          plot_data = gui_to_str(self.plot_data.GetValue()) 
170          norm =      gui_to_bool(self.norm.GetValue()) 
171   
172           
173          file = gui_to_str(self.file.GetValue()) 
174          if not file: 
175              return 
176   
177           
178          force = gui_to_bool(self.force.GetValue()) 
179   
180           
181          self.execute('grace.write', x_data_type=x_data_type, y_data_type=y_data_type, spin_id=spin_id, plot_data=plot_data, file=file, dir=None, force=force, norm=norm) 
 182   
183   
184 -    def update_parameters(self, combo_box): 
 185          """Fill out the list of parameters and their descriptions. 
186   
187          @param combo_box:   The combo box element to update. 
188          @type combo_box:    wx.ComboBox instance 
189          """ 
190   
191           
192          if cdp == None: 
193              gui_raise(RelaxNoPipeError()) 
194              self.setup_fail = True 
195              return 
196   
197           
198          data_names = specific_fns.setup.get_specific_fn('data_names', cdp.pipe_type, raise_error=False) 
199          self.data_type = specific_fns.setup.get_specific_fn('data_type', cdp.pipe_type, raise_error=False) 
200          return_data_desc = specific_fns.setup.get_specific_fn('return_data_desc', cdp.pipe_type, raise_error=False) 
201   
202           
203          try: 
204              names = data_names(set='params') 
205          except RelaxImplementError: 
206              gui_raise(RelaxImplementError()) 
207              self.setup_fail = True 
208              return 
209   
210           
211          combo_box.Clear() 
212          combo_box.Append(str_to_gui("Spin sequence"), 'spin') 
213   
214           
215          for name in (data_names(set='params') + data_names(set='generic')): 
216               
217              desc = return_data_desc(name) 
218   
219               
220              if not desc: 
221                  text = name 
222   
223               
224              else: 
225                  text = "'%s':  %s" % (name, desc) 
226   
227               
228              combo_box.Append(str_to_gui(text), name) 
229   
230           
231          combo_box.SetSelection(0) 
  232