Author: bugman Date: Tue Mar 1 12:15:43 2011 New Revision: 12643 URL: http://svn.gna.org/viewcvs/relax?rev=12643&view=rev Log: Created an initial value.set() user function GUI element and menu entry. Added: 1.3/gui/user_functions/value.py Modified: 1.3/gui/menu.py 1.3/gui/user_functions/__init__.py Modified: 1.3/gui/menu.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/menu.py?rev=12643&r1=12642&r2=12643&view=diff ============================================================================== --- 1.3/gui/menu.py (original) +++ 1.3/gui/menu.py Tue Mar 1 12:15:43 2011 @@ -221,6 +221,9 @@ [wx.NewId(), "crea&te", paths.icon_16x16.add, self.gui.user_functions.spin.create], [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.spin.delete] ]], + [wx.NewId(), "&value", paths.icon_16x16.value, None, [ + [wx.NewId(), "&set", paths.icon_16x16.add, self.gui.user_functions.value.set] + ]] ] # Build. Modified: 1.3/gui/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/user_functions/__init__.py?rev=12643&r1=12642&r2=12643&view=diff ============================================================================== --- 1.3/gui/user_functions/__init__.py (original) +++ 1.3/gui/user_functions/__init__.py Tue Mar 1 12:15:43 2011 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2010 Edward d'Auvergne # +# Copyright (C) 2010-2011 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -34,6 +34,7 @@ from script import Script from sequence import Sequence from spin import Spin +from value import Value # The package __all__ list. @@ -44,7 +45,8 @@ 'relax_data', 'script', 'sequence', - 'spin'] + 'spin', + 'value'] class User_functions: @@ -69,6 +71,7 @@ self.script = Script(self.gui, self.interpreter) self.sequence = Sequence(self.gui, self.interpreter) self.spin = Spin(self.gui, self.interpreter) + self.value = Value(self.gui, self.interpreter) def destroy(self): @@ -81,3 +84,4 @@ self.relax_data.destroy() self.sequence.destroy() self.spin.destroy() + self.value.destroy() Added: 1.3/gui/user_functions/value.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/user_functions/value.py?rev=12643&view=auto ============================================================================== --- 1.3/gui/user_functions/value.py (added) +++ 1.3/gui/user_functions/value.py Tue Mar 1 12:15:43 2011 @@ -1,0 +1,122 @@ +############################################################################### +# # +# Copyright (C) 2011 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +# Module docstring. +"""The value user function GUI elements.""" + +# Python module imports. +from os import sep + +# relax module imports. +from generic_fns import pipes +import specific_fns + +# GUI module imports. +from base import UF_base, UF_window +from gui.misc import gui_to_str, str_to_gui +from gui.paths import WIZARD_IMAGE_PATH + + +# The container class. +class Value(UF_base): + """The container class for holding all GUI elements.""" + + def set(self, event): + """The value.set user function. + + @param event: The wx event. + @type event: wx event + """ + + # The dialog. + window = Set_window(self.gui, self.interpreter) + window.ShowModal() + window.Destroy() + + + +class Set_window(UF_window): + """The user function window.""" + + # Some class variables. + size_x = 800 + size_y = 600 + frame_title = 'Set parameter values' + image_path = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png' + main_text = 'This dialog allows you to set spin specific data values.' + title = 'Value setting' + + + def add_uf(self, sizer): + """Add the sequence specific GUI elements. + + @param sizer: A sizer object. + @type sizer: wx.Sizer instance + """ + + # The parameter. + self.param = self.combo_box(sizer, "The parameter:", []) + + # The value. + self.value = self.input_field(sizer, "The value:") + + # The spin ID restriction. + self.spin_id = self.input_field(sizer, "Restrict data loading to certain spins:", tooltip="This must be a valid spin ID. Multiple spins can be selected using ranges, the '|' operator, residue ranges, etc.") + + + def execute(self): + """Execute the user function.""" + + # The parameter and value. + param = gui_to_str(self.param.GetClientData(self.param.GetSelection())) + value = gui_to_str(self.value.GetValue()) + + # The spin ID. + spin_id = gui_to_str(self.spin_id.GetValue()) + + # Set the value. + self.interpreter.value.set(val=value, param=param, spin_id=spin_id) + + + def update(self, event): + """Update the UI. + + @param event: The wx event. + @type event: wx event + """ + + # Get the specific functions. + data_names = specific_fns.setup.get_specific_fn('data_names', pipes.get_type(), raise_error=False) + return_data_desc = specific_fns.setup.get_specific_fn('return_data_desc', pipes.get_type(), raise_error=False) + + # Loop over the parameters. + for name in data_names(set='params'): + # Get the description. + desc = return_data_desc(name) + + # No description. + if not desc: + desc = name + + # Append the description. + self.param.Append(str_to_gui(desc), name) +