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

Source Code for Module gui.user_functions.pipe

  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 pipe user function GUI elements.""" 
 25   
 26  # Python module imports. 
 27  import wx 
 28   
 29  # relax module imports. 
 30  from generic_fns.pipes import PIPE_DESC_LIST, VALID_TYPES, cdp_name, pipe_names 
 31   
 32  # GUI module imports. 
 33  from base import UF_base, UF_page 
 34  from gui.misc import gui_to_list, gui_to_str, str_to_gui 
 35  from gui.paths import WIZARD_IMAGE_PATH 
 36   
 37   
 38  # The container class. 
39 -class Pipe(UF_base):
40 """The container class for holding all GUI elements.""" 41
42 - def copy(self):
43 """The pipe.copy user function.""" 44 45 # Execute the wizard. 46 wizard = self.create_wizard(size_x=600, size_y=400, name='pipe.copy', uf_page=Copy_page) 47 wizard.run()
48 49
50 - def create(self):
51 """The pipe.create user function.""" 52 53 # Execute the wizard. 54 wizard = self.create_wizard(size_x=700, size_y=500, name='pipe.create', uf_page=Create_page) 55 wizard.run()
56 57
58 - def delete(self):
59 """The pipe.delete user function.""" 60 61 # Execute the wizard. 62 wizard = self.create_wizard(size_x=600, size_y=400, name='pipe.delete', uf_page=Delete_page) 63 wizard.run()
64 65
66 - def hybridise(self):
67 """The pipe.hybridise user function.""" 68 69 # Execute the wizard. 70 wizard = self.create_wizard(size_x=800, size_y=800, name='pipe.hybridise', uf_page=Hybridise_page) 71 wizard.run()
72 73
74 - def switch(self):
75 """The pipe.switch user function.""" 76 77 # Execute the wizard. 78 wizard = self.create_wizard(size_x=650, size_y=450, name='pipe.switch', uf_page=Switch_page, apply_button=False) 79 wizard.run()
80 81 82
83 -class Copy_page(UF_page):
84 """The pipe.copy() user function page.""" 85 86 # Some class variables. 87 image_path = WIZARD_IMAGE_PATH + 'pipe.png' 88 uf_path = ['pipe', 'copy'] 89
90 - def add_contents(self, sizer):
91 """Add the pipe specific GUI elements. 92 93 @param sizer: A sizer object. 94 @type sizer: wx.Sizer instance 95 """ 96 97 # The source pipe. 98 self.pipe_from = self.combo_box(sizer, "Source pipe:", [], tooltip=self.uf._doc_args_dict['pipe_from']) 99 100 # The destination pipe. 101 self.pipe_to = self.input_field(sizer, "Destination pipe name:", tooltip=self.uf._doc_args_dict['pipe_to'])
102 103
104 - def on_display(self):
105 """Clear the data is apply was hit.""" 106 107 # Clear the previous data. 108 self.pipe_from.Clear() 109 110 # Clear the pipe name. 111 self.pipe_from.SetValue(str_to_gui('')) 112 113 # The list of pipe names. 114 for name in pipe_names(): 115 self.pipe_from.Append(str_to_gui(name))
116 117
118 - def on_execute(self):
119 """Execute the user function.""" 120 121 # Get the pipe names. 122 pipe_from = gui_to_str(self.pipe_from.GetValue()) 123 pipe_to = gui_to_str(self.pipe_to.GetValue()) 124 125 # Copy the data pipe. 126 self.execute('pipe.copy', pipe_from, pipe_to)
127 128 129
130 -class Create_page(UF_page):
131 """The pipe.create() user function page.""" 132 133 # Some class variables. 134 image_path = WIZARD_IMAGE_PATH + 'pipe.png' 135 uf_path = ['pipe', 'create'] 136
137 - def add_contents(self, sizer):
138 """Add the pipe specific GUI elements. 139 140 @param sizer: A sizer object. 141 @type sizer: wx.Sizer instance 142 """ 143 144 # The argument GUI elements. 145 self.element_string(key='pipe_name', sizer=sizer, desc="The data pipe name:", tooltip=self.uf._doc_args_dict['pipe_name']) 146 self.element_string(key='pipe_type', element_type='combo', sizer=sizer, desc="The type of data pipe:", combo_choices=PIPE_DESC_LIST, combo_data=VALID_TYPES, tooltip=self.uf._doc_args_dict['pipe_type'], read_only=True)
147 148
149 - def on_execute(self):
150 """Execute the user function.""" 151 152 # Get the argument values. 153 pipe_name = self.GetValue('pipe_name') 154 pipe_type = self.GetValue('pipe_type') 155 156 # Set the name. 157 self.execute('pipe.create', pipe_name=pipe_name, pipe_type=pipe_type)
158 159 160
161 -class Delete_page(UF_page):
162 """The pipe.delete() user function page.""" 163 164 # Some class variables. 165 image_path = WIZARD_IMAGE_PATH + 'pipe.png' 166 uf_path = ['pipe', 'delete'] 167 168
169 - def add_contents(self, sizer):
170 """Add the pipe specific GUI elements. 171 172 @param sizer: A sizer object. 173 @type sizer: wx.Sizer instance 174 """ 175 176 # The argument GUI elements. 177 self.element_string(key='pipe_name', element_type='combo', sizer=sizer, desc="The pipe:", combo_choices=[], tooltip=self.uf._doc_args_dict['pipe_name'])
178 179
180 - def on_display(self):
181 """Clear and update the pipe name list.""" 182 183 # Reset the list. 184 self.ResetChoices('pipe_name', combo_choices=pipe_names())
185 186
187 - def on_execute(self):
188 """Execute the user function.""" 189 190 # Get the argument values. 191 pipe_name = self.GetValue('pipe_name') 192 193 # Delete the data pipe. 194 self.execute('pipe.delete', pipe_name)
195 196 197
198 -class Hybridise_page(UF_page):
199 """The pipe.hybridise() user function page.""" 200 201 # Some class variables. 202 image_path = WIZARD_IMAGE_PATH + 'pipe_hybrid.png' 203 uf_path = ['pipe', 'hybridise'] 204 205
206 - def add_contents(self, sizer):
207 """Add the pipe specific GUI elements. 208 209 @param sizer: A sizer object. 210 @type sizer: wx.Sizer instance 211 """ 212 213 # The argument GUI elements. 214 self.element_string(key='hybrid', sizer=sizer, desc="The hybrid pipe name:", tooltip=self.uf._doc_args_dict['hybrid']) 215 self.element_string_list(key='pipes', element_type='combo_list', sizer=sizer, desc="The pipes to hybridise:", combo_choices=pipe_names(), combo_list_size=2, tooltip=self.uf._doc_args_dict['pipes'])
216 217
218 - def on_execute(self):
219 """Execute the user function.""" 220 221 # Get the argument values. 222 hybrid = self.GetValue('hybrid') 223 pipes = self.GetValue('pipes') 224 225 # Delete the data pipe. 226 self.execute('pipe.hybridise', hybrid=hybrid, pipes=pipes)
227 228 229
230 -class Switch_page(UF_page):
231 """The pipe.switch() user function page.""" 232 233 # Some class variables. 234 image_path = WIZARD_IMAGE_PATH + 'pipe_switch.png' 235 uf_path = ['pipe', 'switch'] 236
237 - def add_contents(self, sizer):
238 """Add the pipe specific GUI elements. 239 240 @param sizer: A sizer object. 241 @type sizer: wx.Sizer instance 242 """ 243 244 # The current data pipe. 245 self.cdp = self.text(sizer, "The current data pipe (cdp):") 246 247 # The pipe selection. 248 self.pipe_name = self.combo_box(sizer, "The pipe:", [], tooltip=self.uf._doc_args_dict['pipe_name'])
249 250
251 - def on_display(self):
252 """Clear and update the pipe name list and cdp.""" 253 254 # Clear the previous data. 255 self.pipe_name.Clear() 256 self.cdp.Clear() 257 258 # Clear the pipe name. 259 self.pipe_name.SetValue(str_to_gui('')) 260 self.cdp.SetValue(str_to_gui(cdp_name())) 261 262 # The list of pipe names. 263 for name in pipe_names(): 264 self.pipe_name.Append(str_to_gui(name))
265 266
267 - def on_execute(self):
268 """Execute the user function.""" 269 270 # Get the name. 271 pipe_name = str(self.pipe_name.GetValue()) 272 273 # Switch the data pipe. 274 self.execute('pipe.switch', pipe_name)
275