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

Source Code for Module gui.user_functions.results

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 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 results 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.misc import gui_to_bool, gui_to_float, gui_to_int, gui_to_str, int_to_gui, str_to_gui 
 33   
 34   
 35  # The container class. 
36 -class Results(UF_base):
37 """The container class for holding all GUI elements.""" 38
39 - def display(self):
40 """The results.display user function.""" 41 42 # Execute the wizard. 43 wizard = self.create_wizard(size_x=600, size_y=300, name='results.display', uf_page=Display_page, apply_button=False) 44 wizard.run()
45 46
47 - def read(self):
48 """The results.read user function.""" 49 50 # Execute the wizard. 51 wizard = self.create_wizard(size_x=700, size_y=500, name='results.read', uf_page=Read_page, apply_button=False) 52 wizard.run()
53 54
55 - def write(self):
56 """The results.write user function.""" 57 58 # Execute the wizard. 59 wizard = self.create_wizard(size_x=900, size_y=700, name='results.write', uf_page=Write_page, apply_button=False) 60 wizard.run()
61 62 63
64 -class Display_page(UF_page):
65 """The results.display() user function page.""" 66 67 # Some class variables. 68 uf_path = ['results', 'display'] 69
70 - def add_contents(self, sizer):
71 """Add the specific GUI elements. 72 73 @param sizer: A sizer object. 74 @type sizer: wx.Sizer instance 75 """
76 77
78 - def on_execute(self):
79 """Execute the user function.""" 80 81 # Execute the user function. 82 self.execute('results.display')
83 84 85
86 -class Read_page(UF_page):
87 """The results.read() user function page.""" 88 89 # Some class variables. 90 uf_path = ['results', 'read'] 91
92 - def add_contents(self, sizer):
93 """Add the specific GUI elements. 94 95 @param sizer: A sizer object. 96 @type sizer: wx.Sizer instance 97 """ 98 99 # Add a file selection. 100 self.file = self.file_selection(sizer, "The results file:", message="Results file selection", wildcard='relax results files (*.bz2)|*.bz2|relax results files (*.gz)|*.gz|relax results files (*.*)|*.*', style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
101 102
103 - def on_execute(self):
104 """Execute the user function.""" 105 106 # The file name. 107 file = gui_to_str(self.file.GetValue()) 108 109 # No file. 110 if not file: 111 return 112 113 # Execute the user function. 114 self.execute('results.read', file=file)
115 116 117
118 -class Write_page(UF_page):
119 """The results.write() user function page.""" 120 121 # Some class variables. 122 height_desc = 400 123 uf_path = ['results', 'write'] 124
125 - def add_contents(self, sizer):
126 """Add the specific GUI elements. 127 128 @param sizer: A sizer object. 129 @type sizer: wx.Sizer instance 130 """ 131 132 # Add a file selection. 133 self.file = self.file_selection(sizer, "The results file:", message="Results file selection", wildcard='relax results files (*.bz2)|*.bz2|relax results files (*.gz)|*.gz|relax results files (*.*)|*.*', style=wx.FD_SAVE, tooltip=self.uf._doc_args_dict['file']) 134 135 # The force flag. 136 self.force = self.boolean_selector(sizer, "Force flag:", tooltip=self.uf._doc_args_dict['force']) 137 138 # The compression type. 139 self.compress_type = self.combo_box(sizer, "The compression type:", ["0: No compression.", "1: Bzip2 compression.", "2: Gzip compression."], tooltip=self.uf._doc_args_dict['compress_type'], read_only=True) 140 self.compress_type.SetSelection(1)
141 142
143 - def on_execute(self):
144 """Execute the user function.""" 145 146 # The file name. 147 file = gui_to_str(self.file.GetSelection()) 148 149 # No file. 150 if not file: 151 return 152 153 # Get the values. 154 compress_type = gui_to_int(self.compress_type.GetValue()) 155 force = gui_to_bool(self.force.GetValue()) 156 157 # Execute the user function. 158 self.execute('results.write', file=file, force=force, compress_type=compress_type)
159