Author: bugman Date: Tue Dec 7 00:10:30 2010 New Revision: 11714 URL: http://svn.gna.org/viewcvs/relax?rev=11714&view=rev Log: The script user function GUI element is now functional. Added: branches/bieri_gui/gui_bieri/user_functions/script.py Modified: branches/bieri_gui/gui_bieri/relax_gui.py branches/bieri_gui/gui_bieri/user_functions/__init__.py Modified: branches/bieri_gui/gui_bieri/relax_gui.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/relax_gui.py?rev=11714&r1=11713&r2=11714&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/relax_gui.py (original) +++ branches/bieri_gui/gui_bieri/relax_gui.py Tue Dec 7 00:10:30 2010 @@ -61,6 +61,7 @@ from references import References from relax_prompt import Prompt from settings import import_file_settings, load_sequence, relax_global_settings +from user_functions import User_functions # Variables. @@ -113,6 +114,9 @@ # Initialise the GUI data. self.init_data() + # The user function GUI elements. + self.user_functions = User_functions(self) + # Build the main window. self.build_main_window() @@ -302,11 +306,11 @@ # The 'User functions' menu entries. menu = wx.Menu() - menu.AppendItem(self.build_menu_sub_item(menu, id=10, text="&Script", icon=paths.UF_SCRIPT_ICON)) + menu.AppendItem(self.build_menu_sub_item(menu, id=30, text="&script", icon=paths.UF_SCRIPT_ICON)) menubar.Append(menu, "&User functions") # The 'User functions' menu actions. - #self.Bind(wx.EVT_MENU, self.user_functions.script, id=10) + self.Bind(wx.EVT_MENU, self.user_functions.script.run, id=30) # The 'Molecule' menu entries. menu = wx.Menu() Modified: branches/bieri_gui/gui_bieri/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/__init__.py?rev=11714&r1=11713&r2=11714&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/user_functions/__init__.py (original) +++ branches/bieri_gui/gui_bieri/user_functions/__init__.py Tue Dec 7 00:10:30 2010 @@ -23,4 +23,30 @@ # Package docstring. """User function GUI elements.""" -__all__ = ['relax_gui'] +# relax module imports. +from prompt.interpreter import Interpreter + +# GUI module imports. +from script import Script + + +# The package __all__ list. +__all__ = ['script'] + + +class User_functions: + """Container for all the user function GUI elements.""" + + def __init__(self, gui): + """Set up the container.""" + + # Store the args. + self.gui = gui + + # Load the interpreter. + self.interpreter = Interpreter(show_script=True, quit=False, raise_relax_error=True) + self.interpreter.populate_self() + self.interpreter.on(verbose=False) + + # The user functions. + self.script = Script(self.gui, self.interpreter) Added: branches/bieri_gui/gui_bieri/user_functions/script.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/script.py?rev=11714&view=auto ============================================================================== --- branches/bieri_gui/gui_bieri/user_functions/script.py (added) +++ branches/bieri_gui/gui_bieri/user_functions/script.py Tue Dec 7 00:10:30 2010 @@ -1,0 +1,59 @@ +############################################################################### +# # +# Copyright (C) 2010 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 script user functions.""" + +# GUI module imports. +from gui_bieri.filedialog import openfile + + +class Script: + """The script user function GUI class.""" + + def __init__(self, gui, interpreter): + """Set up the user function class.""" + + # Store the args. + self.gui = gui + self.interpreter = interpreter + + + def run(self, event): + """The script user function GUI element. + + @param event: The wx event. + @type event: wx event + """ + + # User selection of the file. + file = openfile(msg='Select the relax script to execute') + + # Show the relax controller. + self.gui.controller.Show() + + # Check the file. + if not file: + return + + # Execute the user function. + self.interpreter.script(str(file))