Author: bugman Date: Fri May 4 11:04:38 2012 New Revision: 15957 URL: http://svn.gna.org/viewcvs/relax?rev=15957&view=rev Log: Started to write the auto-generated user function GUI menu. Modified: branches/uf_redesign/gui/menu.py branches/uf_redesign/user_functions/objects.py branches/uf_redesign/user_functions/pipe.py Modified: branches/uf_redesign/gui/menu.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/menu.py?rev=15957&r1=15956&r2=15957&view=diff ============================================================================== --- branches/uf_redesign/gui/menu.py (original) +++ branches/uf_redesign/gui/menu.py Fri May 4 11:04:38 2012 @@ -29,6 +29,7 @@ # relax module imports. from status import Status; status = Status() +from user_functions.data import Uf_info; uf_info = Uf_info() # relax GUI module imports. from gui import paths @@ -114,6 +115,9 @@ self.gui.Bind(wx.EVT_MENU, self.gui.show_pipe_editor, id=self.MENU_VIEW_PIPE_EDIT) # The 'User functions' menu entries. + self._user_functions_old() + + # The auto generated 'User functions' menu entries. self._user_functions() # The 'Tools' menu entries. @@ -236,16 +240,53 @@ def _user_functions(self): - """Build the user function sub-menu.""" + """Auto-generate the user function sub-menu.""" # The menu. menu = wx.Menu() + # Initialise some variables. + class_list = [] + + # The user functions. + user_functions = User_functions(self.gui) + + # Loop over the user functions. + for name, data in uf_info.uf_loop(): + # Split up the name. + class_name, uf_name = split(name, '.') + + # Generate a submenu. + if class_name not in class_list: + # Get the user function class data object. + data = uf_info.get_class(class_name) + + # Create a unique ID. + class_id = wx.NewId() + + # Create the submenu. + menu.AppendItem(build_menu_item(menu, id=class_id, text=data.menu_text, icon=fetch_icon(data.gui_icon))) + # Add the menu. uf_menus = Uf_menus(parent=self.gui, menu=menu) # Add the sub-menu. title = "&User functions" + self.menubar.Append(menu, title) + self.menu_uf_id = self.menubar.FindMenu(title) + + + def _user_functions_old(self): + """Build the user function sub-menu.""" + + # The menu. + menu = wx.Menu() + + # Add the menu. + uf_menus = Uf_menus(parent=self.gui, menu=menu) + + # Add the sub-menu. + title = "&User functions old" self.menubar.Append(menu, title) self.menu_uf_id = self.menubar.FindMenu(title) Modified: branches/uf_redesign/user_functions/objects.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/objects.py?rev=15957&r1=15956&r2=15957&view=diff ============================================================================== --- branches/uf_redesign/user_functions/objects.py (original) +++ branches/uf_redesign/user_functions/objects.py Fri May 4 11:04:38 2012 @@ -31,11 +31,18 @@ """This class is used to process and store all of the user function class information. @ivar title: The user function class description. + @type title: str + @ivar menu_text: The text to use for the GUI menu entry. + @type menu_text: str + @ivar gui_icon: The code for the icon to use in the GUI. + @type gui_icon: str or None """ # The list of modifiable objects (anything else will be rejected to prevent coding errors). __mod_attr__ = [ - 'title' + 'title', + 'menu_text', + 'gui_icon' ] def __init__(self): @@ -43,6 +50,8 @@ # Initialise the variables for all user function classes. self.title = None + self.menu_text = None + self.gui_icon = None def __setattr__(self, name, value): Modified: branches/uf_redesign/user_functions/pipe.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/pipe.py?rev=15957&r1=15956&r2=15957&view=diff ============================================================================== --- branches/uf_redesign/user_functions/pipe.py (original) +++ branches/uf_redesign/user_functions/pipe.py Fri May 4 11:04:38 2012 @@ -32,6 +32,8 @@ # The user function class. uf_class = uf_info.add_class('pipe') uf_class.title = "Class holding the user functions for manipulating data pipes." +uf_class.menu_text = "&pipe" +uf_class.gui_icon = "relax.pipe" # The pipe.copy user function. uf = uf_info.add_uf('pipe.copy')