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

Source Code for Module gui.user_functions.molmol

  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  """The molmol user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  from os import sep 
 28  import wx 
 29   
 30  # GUI module imports. 
 31  from base import UF_base, UF_page 
 32  from gui.paths import WIZARD_IMAGE_PATH 
 33  from gui.misc import gui_to_bool, gui_to_float, gui_to_int, gui_to_str, str_to_gui 
 34   
 35   
 36  # The container class. 
37 -class Molmol(UF_base):
38 """The container class for holding all GUI elements.""" 39
40 - def clear_history(self):
41 """The molmol.clear_history user function.""" 42 43 # Execute the wizard. 44 wizard = self.create_wizard(size_x=600, size_y=300, name='molmol.clear_history', uf_page=Clear_history_page, apply_button=False) 45 wizard.run()
46 47
48 - def command(self):
49 """The molmol.command user function.""" 50 51 # Execute the wizard. 52 wizard = self.create_wizard(size_x=700, size_y=400, name='molmol.command', uf_page=Command_page) 53 wizard.run()
54 55
56 - def macro_apply(self):
57 """The molmol.macro_apply user function.""" 58 59 # Execute the wizard. 60 wizard = self.create_wizard(size_x=1000, size_y=750, name='molmol.macro_apply', uf_page=Macro_apply_page) 61 wizard.run()
62 63
64 - def macro_run(self, file=None):
65 """The molmol.macro_run user function. 66 67 @keyword file: The macro file to start the user function with. 68 @type file: str 69 """ 70 71 # Create the wizard. 72 wizard, page = self.create_wizard(size_x=800, size_y=400, name='molmo.macro_run', uf_page=Macro_run_page, return_page=True) 73 74 # Default file name. 75 if file: 76 page.file.SetValue(str_to_gui(file)) 77 78 # Execute the wizard. 79 wizard.run()
80 81
82 - def macro_write(self):
83 """The molmol.macro_write user function.""" 84 85 # Execute the wizard. 86 wizard = self.create_wizard(size_x=1000, size_y=750, name='molmol.macro_write', uf_page=Macro_write_page) 87 wizard.run()
88 89
90 - def ribbon(self):
91 """The molmol.ribbon user function.""" 92 93 # Execute the wizard. 94 wizard = self.create_wizard(size_x=700, size_y=400, name='molmol.ribbon', uf_page=Ribbon_page, apply_button=False) 95 wizard.run()
96 97
98 - def tensor_pdb(self):
99 """The molmol.tensor_pdb user function.""" 100 101 # Execute the wizard. 102 wizard = self.create_wizard(size_x=1000, size_y=700, name='molmol.tensor_pdb', uf_page=Tensor_pdb_page, apply_button=False) 103 wizard.run()
104 105
106 - def view(self):
107 """The molmol.view user function.""" 108 109 # Execute the wizard. 110 wizard = self.create_wizard(size_x=600, size_y=300, name='molmol.view', uf_page=View_page, apply_button=False) 111 wizard.run()
112 113 114
115 -class Clear_history_page(UF_page):
116 """The molmol.clear_history() user function page.""" 117 118 # Some class variables. 119 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 120 uf_path = ['molmol', 'clear_history'] 121
122 - def add_contents(self, sizer):
123 """Add the specific GUI elements. 124 125 @param sizer: A sizer object. 126 @type sizer: wx.Sizer instance 127 """
128 129
130 - def on_execute(self):
131 """Execute the user function.""" 132 133 # Execute the user function. 134 self.execute('molmol.clear_history')
135 136 137
138 -class Command_page(UF_page):
139 """The molmol.command() user function page.""" 140 141 # Some class variables. 142 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 143 uf_path = ['molmol', 'command'] 144
145 - def add_contents(self, sizer):
146 """Add the specific GUI elements. 147 148 @param sizer: A sizer object. 149 @type sizer: wx.Sizer instance 150 """ 151 152 # The command. 153 self.command = self.input_field(sizer, "The Molmol command:", tooltip=self.uf._doc_args_dict['command'])
154 155
156 - def on_execute(self):
157 """Execute the user function.""" 158 159 # Get the values. 160 command = gui_to_str(self.command.GetValue()) 161 162 # Execute the user function. 163 self.execute('molmol.command', command=command)
164 165 166
167 -class Macro_apply_page(UF_page):
168 """The molmol.macro_apply() user function page.""" 169 170 # Some class variables. 171 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 172 uf_path = ['molmol', 'macro_apply'] 173 height_desc = 450 174
175 - def add_contents(self, sizer):
176 """Add the specific GUI elements. 177 178 @param sizer: A sizer object. 179 @type sizer: wx.Sizer instance 180 """ 181 182 # The data type. 183 self.data_type = self.combo_box(sizer, "The data type:", choices=['s2', 's2f', 's2s', 'amp_fast', 'amp_slow', 'te', 'tf', 'ts', 'time_fast', 'time_slow', 'rex'], tooltip=self.uf._doc_args_dict['data_type']) 184 185 # The style. 186 self.style = self.input_field(sizer, "The style:", tooltip=self.uf._doc_args_dict['style']) 187 self.style.SetValue(str_to_gui("classic")) 188 189 # The starting colour. 190 self.colour_start = self.input_field(sizer, "The starting colour:", tooltip=self.uf._doc_args_dict['colour_start']) 191 192 # The ending colour. 193 self.colour_end = self.input_field(sizer, "The ending colour:", tooltip=self.uf._doc_args_dict['colour_end']) 194 195 # The colour list. 196 self.colour_list = self.input_field(sizer, "The colour list:", tooltip=self.uf._doc_args_dict['colour_list'])
197 198
199 - def on_execute(self):
200 """Execute the user function.""" 201 202 # Get the values. 203 data_type = gui_to_str(self.data_type.GetValue()) 204 style = gui_to_str(self.style.GetValue()) 205 colour_start = gui_to_str(self.colour_start.GetValue()) 206 colour_end = gui_to_str(self.colour_end.GetValue()) 207 colour_list = gui_to_str(self.colour_list.GetValue()) 208 209 # Execute the user function. 210 self.execute('molmol.macro_apply', data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list)
211 212 213
214 -class Macro_run_page(UF_page):
215 """The molmol.macro_run() user function page.""" 216 217 # Some class variables. 218 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 219 uf_path = ['molmol', 'macro_run'] 220
221 - def add_contents(self, sizer):
222 """Add the specific GUI elements. 223 224 @param sizer: A sizer object. 225 @type sizer: wx.Sizer instance 226 """ 227 228 # Add a file selection. 229 self.file = self.file_selection(sizer, "The macro file:", message="Molmol macro file selection", wildcard="Molmol macro files (*.mac)|*.mac;*.MAC", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
230 231
232 - def on_execute(self):
233 """Execute the user function.""" 234 235 # The file name. 236 file = gui_to_str(self.file.GetValue()) 237 if not file: 238 return 239 240 # Execute the user function. 241 self.execute('molmol.macro_run', file=file, dir=None)
242 243 244
245 -class Macro_write_page(UF_page):
246 """The molmol.macro_write() user function page.""" 247 248 # Some class variables. 249 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 250 uf_path = ['molmol', 'macro_write'] 251 height_desc = 400 252
253 - def add_contents(self, sizer):
254 """Add the specific GUI elements. 255 256 @param sizer: A sizer object. 257 @type sizer: wx.Sizer instance 258 """ 259 260 # Add a file selection. 261 self.file = self.file_selection(sizer, "The macro file:", message="Molmol macro file selection", wildcard="Molmol macro files (*.mac)|*.mac;*.MAC", style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 262 263 # The force flag. 264 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force'], default=True) 265 266 # The data type. 267 self.data_type = self.combo_box(sizer, "The data type:", choices=['s2', 's2f', 's2s', 'amp_fast', 'amp_slow', 'te', 'tf', 'ts', ' time_fast', 'time_slow', 'rex'], tooltip=self.uf._doc_args_dict['data_type']) 268 269 # The style. 270 self.style = self.input_field(sizer, "The style:", tooltip=self.uf._doc_args_dict['style']) 271 self.style.SetValue(str_to_gui("classic")) 272 273 # The starting colour. 274 self.colour_start = self.input_field(sizer, "The starting colour:", tooltip=self.uf._doc_args_dict['colour_start']) 275 276 # The ending colour. 277 self.colour_end = self.input_field(sizer, "The ending colour:", tooltip=self.uf._doc_args_dict['colour_end']) 278 279 # The colour list. 280 self.colour_list = self.input_field(sizer, "The colour list:", tooltip=self.uf._doc_args_dict['colour_list'])
281 282
283 - def on_execute(self):
284 """Execute the user function.""" 285 286 # The file name. 287 file = gui_to_str(self.file.GetValue()) 288 if not file: 289 return 290 291 # Force flag. 292 force = gui_to_bool(self.force.GetValue()) 293 294 # Get the values. 295 data_type = gui_to_str(self.data_type.GetValue()) 296 style = gui_to_str(self.style.GetValue()) 297 colour_start = gui_to_str(self.colour_start.GetValue()) 298 colour_end = gui_to_str(self.colour_end.GetValue()) 299 colour_list = gui_to_str(self.colour_list.GetValue()) 300 301 # Execute the user function. 302 self.execute('molmol.macro_write', data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list, file=file, dir=None, force=force)
303 304 305
306 -class Ribbon_page(UF_page):
307 """The molmol.ribbon() user function page.""" 308 309 # Some class variables. 310 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 311 uf_path = ['molmol', 'ribbon'] 312
313 - def add_contents(self, sizer):
314 """Add the specific GUI elements. 315 316 @param sizer: A sizer object. 317 @type sizer: wx.Sizer instance 318 """
319 320
321 - def on_execute(self):
322 """Execute the user function.""" 323 324 # Execute the user function. 325 self.execute('molmol.ribbon')
326 327 328
329 -class Tensor_pdb_page(UF_page):
330 """The molmol.tensor_pdb() user function page.""" 331 332 # Some class variables. 333 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 334 uf_path = ['molmol', 'tensor_pdb'] 335 height_desc = 450 336
337 - def add_contents(self, sizer):
338 """Add the specific GUI elements. 339 340 @param sizer: A sizer object. 341 @type sizer: wx.Sizer instance 342 """ 343 344 # Add a file selection. 345 self.file = self.file_selection(sizer, "The tensor PDB file:", message="Tensor PDB file selection", wildcard="PDB files (*.pdb)|*.pdb;*.PDB", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
346 347
348 - def on_execute(self):
349 """Execute the user function.""" 350 351 # The file name. 352 file = gui_to_str(self.file.GetValue()) 353 354 # No file. 355 if not file: 356 return 357 358 # Execute the user function. 359 self.execute('molmol.tensor_pdb', file=file)
360 361 362
363 -class View_page(UF_page):
364 """The molmol.view() user function page.""" 365 366 # Some class variables. 367 image_path = WIZARD_IMAGE_PATH + 'molmol' + sep + 'molmol_logo.png' 368 uf_path = ['molmol', 'view'] 369
370 - def add_contents(self, sizer):
371 """Add the specific GUI elements. 372 373 @param sizer: A sizer object. 374 @type sizer: wx.Sizer instance 375 """
376 377
378 - def on_execute(self):
379 """Execute the user function.""" 380 381 # Execute the user function. 382 self.execute('molmol.view')
383