class Data_pipe_page(Wiz_page): """The panel for setting the data pipe name.""" # Class variables. image_path = WIZARD_IMAGE_PATH + 'pipe.png' main_text = "Select the name of the data pipe used at the start of the analysis and the name of the data pipe bundle to be associated with this analysis. All data in relax is kept within a special structure known as the relax data store. This store is composed of multiple data pipes, each being associated with a specific analysis type. Data pipe bundles are simple groupings of the pipes within the data store and each analysis tab is coupled to a specific bundle.\n\nSimple analyses such as the steady-state NOE and the %s and %s curve-fitting will be located within a single data pipe. More complex analyses such as the automated model-free analysis will be spread across multiple data pipes, internally created by forking the original data pipe which holds the input data, all grouped together within a single bundle.\n\nThe initialisation of a new analysis will call the pipe.create user function with the pipe name and pipe bundle as given below." % (r1, r2) title = 'Data pipe set up' def add_contents(self, sizer): """Add the specific GUI elements (dummy method). @param sizer: A sizer object. @type sizer: wx.Sizer instance """ # The pipe name input. self.pipe_name = Value(name='pipe_name', parent=self, value_type='str', sizer=sizer, desc="The starting data pipe for the analysis:", divider=self._div_left, height_element=self.height_element) # The pipe bundle input. self.pipe_bundle = Value(name='pipe_bundle', parent=self, value_type='str', sizer=sizer, desc="The data pipe bundle:", divider=self._div_left, height_element=self.height_element) # Spacing. sizer.AddStretchSpacer(3) def on_display(self): """Update the pipe name.""" # Generate a name for the data pipe bundle based on the type and time. name = "%s (%s)" % (self.parent.analysis_type, asctime(localtime())) # Update the fields. self.pipe_name.SetValue(str_to_gui("origin - %s" % name)) self.pipe_bundle.SetValue(str_to_gui(name))
class Free_file_format: """GUI element for the free file format. This is used for specifying the columns used for the molecule name, residue name and number, spin name and number and data and error columns. """ size_square_button = (33, 33) def __init__(self, parent=None, element_type='default', sizer=None, divider=None, padding=10, spacer=3, height_element=27, data_cols=False, save=True, reset=True): """Build the free format file settings widget. @keyword parent: The parent wx GUI element. @type parent: wx object @keyword element_type: The type of GUI element to create. The value of 'default' creates the large GUI element with a row for each column and for the separator. If 'mini' is supplied, the single row element will be used. @type element_type: str @keyword sizer: The sizer to put the GUI element into. @type sizer: wx.Sizer instance @keyword divider: The position of the divider. @type divider: int @keyword padding: The size of the padding between the wx.StaticBoxSizer border and the internal elements, in pixels. @type padding: int @keyword spacer: The horizontal spacing between the elements, in pixels. @type spacer: int @keyword height_element: The height in pixels of the GUI element. This is only used for the mini format. @type height_element: int @keyword data_cols: A flag which if True causes the data and error column elements to be displayed. @type data_cols: bool @keyword save: A flag which if True will cause the save button to be displayed. @type save: bool @keyword reset: A flag which if True will cause the reset button to be displayed. @type reset: bool """ # Store the args. self.parent = parent self.sizer = sizer self.divider = divider self.element_type = element_type self.padding = padding self.spacer = spacer self.height_element = height_element self.data_cols = data_cols self.save_flag = save self.reset_flag = reset # The large GUI element. if self.element_type == 'default': self._build_default() # The mini GUI element. elif self.element_type == 'mini': self._build_mini() # Unknown type. else: raise RelaxError("Unknown free file format element type '%s'." % element_type) def _build_default(self): """Build the default GUI element.""" # A static box to hold all the widgets. box = wx.StaticBox(self.parent, -1, "The free file format settings:") box.SetFont(font.subtitle) # Init. main_sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL) field_sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = wx.BoxSizer(wx.VERTICAL) # The border of the widget. border = wx.BoxSizer() # Place the box sizer inside the border. border.Add(main_sizer, 1, wx.ALL | wx.EXPAND, 0) # Add to the main sizer (followed by stretchable spacing). self.sizer.Add(border, 0, wx.EXPAND) self.sizer.AddStretchSpacer() # Calculate the divider position. divider = self.parent._div_left - border.GetMinSize( )[0] / 2 - self.padding # The columns. self.spin_id_col = Value(name='spin_id_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="spin ID column", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) self.mol_name_col = Value(name='mol_name_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="Molecule name column:", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) self.res_num_col = Value(name='res_num_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="Residue number column:", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) self.res_name_col = Value(name='res_name_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="Residue name column:", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) self.spin_num_col = Value(name='spin_num_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="Spin number column:", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) self.spin_name_col = Value(name='spin_name_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="Spin name column:", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) if self.data_cols: self.data_col = Value(name='data_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="Data column:", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) self.error_col = Value(name='error_col', parent=self.parent, value_type='int', sizer=field_sizer, desc="Error column:", divider=divider, padding=self.padding, spacer=self.spacer, can_be_none=True) # The column separator. self.sep = Value(name='sep', parent=self.parent, element_type='combo', value_type='str', sizer=field_sizer, desc="Column separator:", combo_choices=["white space", ",", ";", ":", ""], divider=divider, padding=self.padding, spacer=self.spacer, read_only=False, can_be_none=True) # Add the field sizer to the main sizer. main_sizer.Add(field_sizer, 1, wx.ALL | wx.EXPAND, 0) # Set the values. self.set_vals() # Buttons! if self.save_flag or self.reset_flag: # Add a save button. if self.save_flag: # Build the button. button = buttons.ThemedGenBitmapTextButton( self.parent, -1, None, "") button.SetBitmapLabel( wx.Bitmap( fetch_icon('oxygen.actions.document-save', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetFont(font.normal) button.SetToolTip( wx.ToolTip( "Save the free file format settings within the relax data store." )) button.SetMinSize(self.size_square_button) # Add the button. button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0) # Padding. button_sizer.AddSpacer(self.padding) # Bind the click event. self.parent.Bind(wx.EVT_BUTTON, self.save, button) # Add a reset button. if self.reset_flag: # Build the button. button = buttons.ThemedGenBitmapTextButton( self.parent, -1, None, "") button.SetBitmapLabel( wx.Bitmap( fetch_icon('oxygen.actions.edit-delete', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetFont(font.normal) button.SetToolTip( wx.ToolTip( "Reset the free file format settings to the original values." )) button.SetMinSize(self.size_square_button) # Add the button. button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0) # Bind the click event. self.parent.Bind(wx.EVT_BUTTON, self.reset, button) # Add the button sizer to the widget (with spacing). main_sizer.AddSpacer(self.padding) main_sizer.Add(button_sizer, 0, wx.ALL, 0) def _build_mini(self): """Build the mini GUI element.""" # Init. sub_sizer = wx.BoxSizer(wx.HORIZONTAL) # Left padding. sub_sizer.AddSpacer(self.padding) # The description. text = wx.StaticText(self.parent, -1, "Free format file settings", style=wx.ALIGN_LEFT) text.SetFont(font.normal) sub_sizer.Add(text, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 0) # The divider. if not self.divider: raise RelaxError("The divider position has not been supplied.") # Spacing. x, y = text.GetSize() if dep_check.wx_classic: sub_sizer.AddSpacer((self.divider - x, 0)) else: sub_sizer.AddSpacer(self.divider - x) # Initialise the text input field. self.field = wx.TextCtrl(self.parent, -1, '') self.field.SetEditable(False) colour = self.parent.GetBackgroundColour() self.field.SetOwnBackgroundColour(colour) self.field.SetMinSize((50, self.height_element)) self.field.SetFont(font.normal) sub_sizer.Add(self.field, 1, wx.ADJUST_MINSIZE | wx.ALIGN_CENTER_VERTICAL, 0) # A little spacing. sub_sizer.AddSpacer(5) # The edit button. button = wx.BitmapButton( self.parent, -1, wx.Bitmap(fetch_icon("oxygen.actions.document-properties"), wx.BITMAP_TYPE_ANY)) button.SetMinSize((self.height_element, self.height_element)) button.SetToolTip( wx.ToolTip("Open the free file format editing window.")) sub_sizer.Add(button, 0, wx.ADJUST_MINSIZE | wx.ALIGN_CENTER_VERTICAL, 0) self.parent.Bind(wx.EVT_BUTTON, self.open_window, button) # Right padding. sub_sizer.AddSpacer(self.padding) # Add to the main sizer. self.sizer.Add(sub_sizer, 1, wx.EXPAND | wx.ALL, 0) # Spacing below the widget. if self.spacer == None: self.sizer.AddStretchSpacer() else: self.sizer.AddSpacer(self.spacer) # Tooltip. tooltip = "The free file format settings." text.SetToolTip(wx.ToolTip(tooltip)) self.field.SetToolTip(wx.ToolTip(tooltip)) # Set the values. self.set_vals() def GetValue(self): """Return the free file format settings as a keyword dictionary. @return: The dictionary of free file format settings. @rtype: dict """ # Initialise. settings = {} # The default GUI element. if self.element_type == 'default': # Get the column numbers. settings['spin_id_col'] = gui_to_int(self.spin_id_col.GetValue()) settings['mol_name_col'] = gui_to_int(self.mol_name_col.GetValue()) settings['res_num_col'] = gui_to_int(self.res_num_col.GetValue()) settings['res_name_col'] = gui_to_int(self.res_name_col.GetValue()) settings['spin_num_col'] = gui_to_int(self.spin_num_col.GetValue()) settings['spin_name_col'] = gui_to_int( self.spin_name_col.GetValue()) if self.data_cols: settings['data_col'] = gui_to_int(self.data_col.GetValue()) settings['error_col'] = gui_to_int(self.error_col.GetValue()) # The column separator. settings['sep'] = str(self.sep.GetValue()) if settings['sep'] == 'white space': settings['sep'] = None # The mini GUI element. elif self.element_type == 'mini': # Convert the values. values = self.from_string(string=gui_to_str(self.field.GetValue())) # Store them. settings['spin_id_col'] = values[0] settings['mol_name_col'] = values[1] settings['res_num_col'] = values[2] settings['res_name_col'] = values[3] settings['spin_num_col'] = values[4] settings['spin_name_col'] = values[5] if self.data_cols: settings['data_col'] = values[6] settings['error_col'] = values[7] settings['sep'] = values[8] else: settings['sep'] = values[6] # Return the settings. return settings def SetValue(self, key, value): """Special method for setting the value of the GUI element corresponding to the key. @param key: The key corresponding to the desired GUI element. This can be one of ['spin_id_col', 'mol_name_col', 'res_num_col', 'res_name_col', 'spin_num_col', 'spin_name_col', 'data_col', 'error_col', 'sep']. @type key: str @param value: The value that the specific GUI element's SetValue() method expects. @type value: unknown """ # The default GUI element. if self.element_type == 'default': # Get the element. obj = getattr(self, key) # Convert the data. if key == 'sep': value = str_to_gui(value) else: value = int_to_gui(value) # Set the value. obj.SetValue(value) # The mini GUI element. elif self.element_type == 'mini': # Get the current values. settings = self.GetValue() # Replace the value. settings[key] = value # Set the values. if self.data_cols: string = self.to_string( spin_id_col=settings['spin_id_col'], mol_name_col=settings['mol_name_col'], res_num_col=settings['res_num_col'], res_name_col=settings['res_name_col'], spin_num_col=settings['spin_num_col'], spin_name_col=settings['spin_name_col'], data_col=settings['data_col'], error_col=settings['error_col'], sep=settings['sep']) else: string = self.to_string( spin_id_col=settings['spin_id_col'], mol_name_col=settings['mol_name_col'], res_num_col=settings['res_num_col'], res_name_col=settings['res_name_col'], spin_num_col=settings['spin_num_col'], spin_name_col=settings['spin_name_col'], sep=settings['sep']) self.field.SetValue(str_to_gui(string)) def from_string(self, string=None): """Convert the free file format variables to string format. @keyword string: The string to convert. @type string: str @return: The spin ID column, molecule name column, residue number column, residue number column, spin number column, spin name column, data column (if active), error column (if active), and column separator. @rtype: list of str or None """ # The number of elements. num = 6 if self.data_cols: num = 8 # Nothing. if string == None: return [None] * num # Store the columns. values = [] temp = string.split(',') for i in range(num): # No value. if temp[i] in ['None', ' None']: values.append(None) # Integer. else: values.append(int(temp[i])) # Handle the separator. temp = string.split('\'') sep = temp[-2] if sep == "white space": values.append(None) else: values.append(sep) # Return the values. return values def open_window(self, event): """Open the free file format editing window. @param event: The wx event. @type event: wx event """ # Build the window. win = Free_file_format_window() # Show the window. if status.show_gui: win.ShowModal() # Set the values. self.set_vals() def reset(self, event): """Reset the free file format widget contents to the original values. @param event: The wx event. @type event: wx event """ # Ask a question. if status.show_gui and Question( 'Would you really like to reset the free file format settings?', parent=self.parent).ShowModal() == wx.ID_NO: return # First reset. ds.relax_gui.free_file_format.reset() # Then update the values. self.set_vals() def save(self, event): """Save the free file format widget contents into the relax data store. @param event: The wx event. @type event: wx event """ # The default GUI element. if self.element_type == 'default': # Get the column numbers. ds.relax_gui.free_file_format.spin_id_col = gui_to_int( self.spin_id_col.GetValue()) ds.relax_gui.free_file_format.mol_name_col = gui_to_int( self.mol_name_col.GetValue()) ds.relax_gui.free_file_format.res_num_col = gui_to_int( self.res_num_col.GetValue()) ds.relax_gui.free_file_format.res_name_col = gui_to_int( self.res_name_col.GetValue()) ds.relax_gui.free_file_format.spin_num_col = gui_to_int( self.spin_num_col.GetValue()) ds.relax_gui.free_file_format.spin_name_col = gui_to_int( self.spin_name_col.GetValue()) # The data and error. if hasattr(self, 'data_col'): ds.relax_gui.free_file_format.data_col = gui_to_int( self.data_col.GetValue()) if hasattr(self, 'error_col'): ds.relax_gui.free_file_format.error_col = gui_to_int( self.error_col.GetValue()) # The column separator. ds.relax_gui.free_file_format.sep = str(self.sep.GetValue()) if ds.relax_gui.free_file_format.sep == 'white space': ds.relax_gui.free_file_format.sep = None # The mini GUI element. elif self.element_type == 'mini': # Get the current values. settings = self.GetValue() # Store the values. ds.relax_gui.free_file_format.spin_id_col = settings['spin_id_col'] ds.relax_gui.free_file_format.mol_name_col = settings[ 'mol_name_col'] ds.relax_gui.free_file_format.res_num_col = settings['res_num_col'] ds.relax_gui.free_file_format.res_name_col = settings[ 'res_name_col'] ds.relax_gui.free_file_format.spin_num_col = settings[ 'spin_num_col'] ds.relax_gui.free_file_format.spin_name_col = settings[ 'spin_name_col'] if self.data_cols: ds.relax_gui.free_file_format.data_col = settings['data_col'] ds.relax_gui.free_file_format.error_col = settings['error_col'] ds.relax_gui.free_file_format.sep = settings['sep'] def set_vals(self): """Set the free file format widget contents to the values from the relax data store.""" # The default GUI element. if self.element_type == 'default': # The column numbers. self.spin_id_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.spin_id_col)) self.mol_name_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.mol_name_col)) self.res_num_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.res_num_col)) self.res_name_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.res_name_col)) self.spin_num_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.spin_num_col)) self.spin_name_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.spin_name_col)) if hasattr(self, 'data_col'): self.data_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.data_col)) if hasattr(self, 'error_col'): self.error_col.SetValue( int_to_gui(ds.relax_gui.free_file_format.error_col)) # The column separator. if not ds.relax_gui.free_file_format.sep: self.sep.SetValue(str_to_gui("white space")) else: self.sep.SetValue(str_to_gui( ds.relax_gui.free_file_format.sep)) # The mini GUI element. elif self.element_type == 'mini': # The string. if self.data_cols: string = self.to_string( spin_id_col=ds.relax_gui.free_file_format.spin_id_col, mol_name_col=ds.relax_gui.free_file_format.mol_name_col, res_num_col=ds.relax_gui.free_file_format.res_num_col, res_name_col=ds.relax_gui.free_file_format.res_name_col, spin_num_col=ds.relax_gui.free_file_format.spin_num_col, spin_name_col=ds.relax_gui.free_file_format.spin_name_col, data_col=ds.relax_gui.free_file_format.data_col, error_col=ds.relax_gui.free_file_format.error_col, sep=ds.relax_gui.free_file_format.sep) else: string = self.to_string( spin_id_col=ds.relax_gui.free_file_format.spin_id_col, mol_name_col=ds.relax_gui.free_file_format.mol_name_col, res_num_col=ds.relax_gui.free_file_format.res_num_col, res_name_col=ds.relax_gui.free_file_format.res_name_col, spin_num_col=ds.relax_gui.free_file_format.spin_num_col, spin_name_col=ds.relax_gui.free_file_format.spin_name_col, sep=ds.relax_gui.free_file_format.sep) self.field.SetValue(str_to_gui(string)) def to_string(self, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, data_col=None, error_col=None, sep=None): """Convert the free file format variables to string format. @keyword spin_id_col: The column containing the spin ID strings (used by the generic intensity file format). If supplied, the mol_name_col, res_name_col, res_num_col, spin_name_col, and spin_num_col arguments must be none. @type spin_id_col: int or None @keyword mol_name_col: The column containing the molecule name information (used by the generic intensity file format). If supplied, spin_id_col must be None. @type mol_name_col: int or None @keyword res_name_col: The column containing the residue name information (used by the generic intensity file format). If supplied, spin_id_col must be None. @type res_name_col: int or None @keyword res_num_col: The column containing the residue number information (used by the generic intensity file format). If supplied, spin_id_col must be None. @type res_num_col: int or None @keyword spin_name_col: The column containing the spin name information (used by the generic intensity file format). If supplied, spin_id_col must be None. @type spin_name_col: int or None @keyword spin_num_col: The column containing the spin number information (used by the generic intensity file format). If supplied, spin_id_col must be None. @type spin_num_col: int or None @keyword sep: The column separator which, if None, defaults to whitespace. @type sep: str or None @return: The string representation of the free file format settings. @rtype: str """ # The string. string = '' string += repr(spin_id_col) string += ', ' + repr(mol_name_col) string += ', ' + repr(res_num_col) string += ', ' + repr(res_name_col) string += ', ' + repr(spin_num_col) string += ', ' + repr(spin_name_col) if self.data_cols: string += ', ' + repr(data_col) string += ', ' + repr(error_col) if not sep: string += ', ' + repr("white space") else: string += ', ' + repr(sep) # Return the string. return string
class New_analysis_page(Wiz_page): """The panel for selection of the new analysis.""" # Class variables. image_path = IMAGE_PATH + "relax.gif" main_text = "A number of automatic analyses to be preformed using relax in GUI mode. Although not as flexible or powerful as the prompt/scripting modes, this provides a quick and easy setup and execution for a number of analysis types. These currently include the calculation of the steady-state NOE, the exponential curve-fitting for the %s and %s relaxation rates, and for a full and automatic model-free analysis using the d'Auvergne and Gooley, 2008b protocol. All analyses perform error propagation using the gold standard Monte Calro simulations. Please select from one of the following analysis types:" % (r1, r2) title = "Start a new analysis" def add_artwork(self, sizer): """Add the artwork to the dialog. @param sizer: A sizer object. @type sizer: wx.Sizer instance """ # Create a vertical box. sizer2 = wx.BoxSizer(wx.VERTICAL) # Add a spacer. sizer2.AddSpacer(30) # Add the graphics. self.image = wx.StaticBitmap(self, -1, bitmap_setup(self.image_path)) sizer2.Add(self.image, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 0) # Nest the sizers. sizer.Add(sizer2) # A spacer. sizer.AddSpacer(self.art_spacing) def add_buttons(self, box): """The widget of analysis buttons. @param box: A sizer object. @type box: wx.BoxSizer instance """ # The sizes. size = (170, 170) # No button is initially selected. self._select_flag = False # The horizontal spacers. sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer2 = wx.BoxSizer(wx.HORIZONTAL) # The NOE button. self.button_noe = self.create_button(id=BUTTON_ID_NOE, box=sizer1, size=size, bmp=ANALYSIS_IMAGE_PATH+"noe_150x150.png", tooltip="Steady-state NOE analysis", fn=self.select_noe) # The R1 button. self.button_r1 = self.create_button(id=BUTTON_ID_R1, box=sizer1, size=size, bmp=ANALYSIS_IMAGE_PATH+"r1_150x150.png", tooltip="%s relaxation curve-fitting analysis" % r1, fn=self.select_r1) # The R2 button. self.button_r2 = self.create_button(id=BUTTON_ID_R2, box=sizer1, size=size, bmp=ANALYSIS_IMAGE_PATH+"r2_150x150.png", tooltip="%s relaxation curve-fitting analysis" % r2, fn=self.select_r2) # The model-free button. self.button_mf = self.create_button(id=BUTTON_ID_MF, box=sizer1, size=size, bmp=ANALYSIS_IMAGE_PATH+"model_free"+sep+"model_free_150x150.png", tooltip="Model-free analysis", fn=self.select_mf) # The relaxation dispersion button. self.button_disp = self.create_button(id=BUTTON_ID_RELAX_DISP, box=sizer2, size=size, bmp=ANALYSIS_IMAGE_PATH+"relax_disp_150x150.png", tooltip="Relaxation dispersion analysis", fn=self.select_disp) # Consistency testing. self.button_consist_test = self.create_button(id=BUTTON_ID_CONSIST_TEST, box=sizer2, size=size, bmp=ANALYSIS_IMAGE_PATH+"consistency_testing_150x70.png", tooltip="Relaxation data consistency testing (disabled)", fn=self.select_consist_test, disabled=True) # The custom analysis button. self.button_custom = self.create_button(id=BUTTON_ID_CUSTOM, box=sizer2, size=size, bmp=ANALYSIS_IMAGE_PATH+"custom_150x150.png", tooltip="Custom analysis (disabled)", fn=self.select_custom, disabled=True) # The blank reserved button. self.button_reserved = self.create_button(id=BUTTON_ID_RESERVED, box=sizer2, size=size, bmp=ANALYSIS_IMAGE_PATH+"blank_150x150.png", tooltip=None, fn=None, disabled=True) # Add the sizers. box.Add(sizer1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) box.Add(sizer2, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) def add_contents(self, sizer): """Add the specific GUI elements (dummy method). @param sizer: A sizer object. @type sizer: wx.Sizer instance """ # Add the button widget. self.add_buttons(sizer) # Add a spacer. sizer.AddStretchSpacer(2) # Add the analysis name field. self.analysis_name = Value(name='analysis_name', parent=self, value_type='str', sizer=sizer, desc="The name of the new analysis:", tooltip='The name of the analysis can be changed to any text.', divider=self._div_left, height_element=self.height_element) def create_button(self, id=-1, box=None, size=None, bmp=None, text='', tooltip='', fn=None, disabled=False): """Create a button for the new analysis selector panel. @keyword id: The unique ID number. @type id: int @keyword box: The box sizer to place the button into. @type box: wx.BoxSizer instance @keyword size: The size of the button. @type size: tuple of int @keyword bmp: The full path of the bitmap image to use for the button. @type bmp: str @keyword text: The text for the button. @type text: str @keyword tooltip: The button tooltip text. @type tooltip: str or None @keyword fn: The function to bind the button click to. @type fn: method @return: The button. @rtype: wx.lib.buttons.ThemedGenBitmapTextToggleButton instance """ # Generate the button. if bmp: image = wx.Bitmap(bmp, wx.BITMAP_TYPE_ANY) button = New_analysis_button(self, id, image) else: button = New_analysis_button(self, id) # Set the tool tip. if tooltip != None: button.SetToolTipString(tooltip) # Button properties. button.SetMinSize(size) # Add to the given sizer. box.Add(button) # Bind the click. if fn != None: self.Bind(wx.EVT_BUTTON, fn, button) # The button is disabled. if disabled: button.Disable() # Return the button. return button def on_display(self): """Disable the next button until an analysis is selected.""" # Turn off the next button. self.parent.block_next(not self._select_flag) def select_consist_test(self, event): """NOE analysis selection. @param event: The wx event. @type event: wx event """ # Toggle all buttons off. self.toggle(self.button_consist_test) # Set the analysis type. self.parent.analysis_type = 'consistency test' def select_custom(self, event): """NOE analysis selection. @param event: The wx event. @type event: wx event """ # Toggle all buttons off. self.toggle(self.button_custom) # Set the analysis type. self.parent.analysis_type = 'custom' def select_disp(self, event): """Relaxation dispersion analysis selection. @param event: The wx event. @type event: wx event """ # Toggle all buttons off. self.toggle(self.button_disp) # Update the analysis name. self.analysis_name.SetValue(str_to_gui('Relaxation dispersion')) # Set the analysis type. self.parent.analysis_type = 'relax_disp' def select_mf(self, event): """NOE analysis selection. @param event: The wx event. @type event: wx event """ # Toggle all buttons off. self.toggle(self.button_mf) # Update the analysis name. self.analysis_name.SetValue(str_to_gui('Model-free')) # Set the analysis type. self.parent.analysis_type = 'mf' def select_noe(self, event): """NOE analysis selection. @param event: The wx event. @type event: wx event """ # Toggle all buttons off. self.toggle(self.button_noe) # Update the analysis name. self.analysis_name.SetValue(str_to_gui('Steady-state NOE')) # Set the analysis type. self.parent.analysis_type = 'noe' def select_r1(self, event): """NOE analysis selection. @param event: The wx event. @type event: wx event """ # Toggle all buttons off. self.toggle(self.button_r1) # Update the analysis name. self.analysis_name.SetValue(str_to_gui("R1 relaxation")) # Set the analysis type. self.parent.analysis_type = 'r1' def select_r2(self, event): """NOE analysis selection. @param event: The wx event. @type event: wx event """ # Toggle all buttons off. self.toggle(self.button_r2) # Update the analysis name. self.analysis_name.SetValue(str_to_gui("R2 relaxation")) # Set the analysis type. self.parent.analysis_type = 'r2' def toggle(self, button): """Toggle all buttons off except the selected one. @param button: The button of the selected analysis. @type button: wx.ToggleButton instance """ # First freeze the wizard. self.Freeze() # The button is selected. self._select_flag = True # Deselect all. self.button_noe.SetValue(False) self.button_r1.SetValue(False) self.button_r2.SetValue(False) self.button_mf.SetValue(False) self.button_disp.SetValue(False) self.button_consist_test.SetValue(False) self.button_custom.SetValue(False) self.button_reserved.SetValue(False) # Turn on the selected button. button.SetValue(True) # Refresh the GUI element. self.Refresh() # Unfreeze. self.Thaw() # Unblock forwards movement. self.parent.block_next(not self._select_flag)