mailr16270 - /branches/uf_redesign/gui/menu.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on May 13, 2012 - 12:27:
Author: bugman
Date: Sun May 13 12:27:46 2012
New Revision: 16270

URL: http://svn.gna.org/viewcvs/relax?rev=16270&view=rev
Log:
Eliminated the old user function menu system.

The auto-generated menu system is now complete, so the old system is now of 
no use.


Modified:
    branches/uf_redesign/gui/menu.py

Modified: branches/uf_redesign/gui/menu.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/menu.py?rev=16270&r1=16269&r2=16270&view=diff
==============================================================================
--- branches/uf_redesign/gui/menu.py (original)
+++ branches/uf_redesign/gui/menu.py Sun May 13 12:27:46 2012
@@ -22,7 +22,7 @@
 
###############################################################################
 
 # Module docstring.
-"""Module for the main relax menu bar."""
+"""The main relax menu bar."""
 
 # Python module imports.
 from re import search
@@ -118,9 +118,6 @@
         self.gui.Bind(wx.EVT_MENU, self.gui.show_results_viewer, 
id=self.MENU_VIEW_RESULTS)
         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()
 
@@ -316,21 +313,6 @@
         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)
-
-
     def update_menus(self, event):
         """Update the menus dependent on the relax state.
 
@@ -368,234 +350,3 @@
             if submenu:
                 for subitem in submenu.GetMenuItems():
                     subitem.Enable(enable)
-
-
-
-class Uf_menus:
-    """A class for the creation of specialised menu entries for the user 
functions."""
-
-    def __init__(self, parent=None, menu=None):
-        """Set up the menu entries.
-
-        @keyword parent:    The parent window.
-        @type parent:       wx.Window instance
-        @keyword menu:      The menu to add to.
-        @type menu:         wx.Menu instance
-        """
-
-        # Store the args.
-        self.parent = parent
-        self.menu = menu
-
-        # The user functions.
-        user_functions = User_functions(self.parent)
-
-        # Initialise some data structures.
-        self.uf_names = {}
-        self.uf = {}
-
-        # Build the user function menus.
-        id = self.add_class(name="bmrb", text="&bmrb", 
icon=paths.icon_16x16.bmrb)
-        self.add_uf(parent_id=id, name="bmrb.citation", text="&citation", 
fn=user_functions.bmrb.citation)
-
-        id = self.add_class(name="bruker", text="&bruker", 
icon=paths.icon_16x16.bruker)
-        self.add_uf(parent_id=id, name="bruker.read", text="&read", 
icon=paths.icon_16x16.open, fn=user_functions.bruker.read)
-
-        id = self.add_class(name="deselect", text="&deselect", icon=None)
-        self.add_uf(parent_id=id, name="deselect.all", text="&all", 
icon=None, fn=user_functions.deselect.all)
-        self.add_uf(parent_id=id, name="deselect.read", text="&read", 
icon=paths.icon_16x16.open, fn=user_functions.deselect.read)
-        self.add_uf(parent_id=id, name="deselect.reverse", text="re&verse", 
icon=None, fn=user_functions.deselect.reverse)
-        self.add_uf(parent_id=id, name="deselect.spin", text="&spin", 
icon=paths.icon_16x16.spin, fn=user_functions.deselect.spin)
-
-        self.add_uf(parent_id=None, name="gpl", text="&gpl", 
icon=paths.icon_16x16.gnu_head, fn=user_functions.gpl.run)
-
-        id = self.add_class(name="grace", text="gra&ce", 
icon=paths.icon_16x16.grace)
-        self.add_uf(parent_id=id, name="grace.view", text="&view", 
icon=paths.icon_16x16.grace, fn=user_functions.grace.view)
-        self.add_uf(parent_id=id, name="grace.write", text="&write", 
icon=paths.icon_16x16.save, fn=user_functions.grace.write)
-
-        id = self.add_class(name="molecule", text="&molecule", 
icon=paths.icon_16x16.molecule)
-        self.add_uf(parent_id=id, name="molecule.copy", text="&copy", 
icon=paths.icon_16x16.copy, fn=user_functions.molecule.copy)
-        self.add_uf(parent_id=id, name="molecule.create", text="crea&te", 
icon=paths.icon_16x16.add, fn=user_functions.molecule.create)
-        self.add_uf(parent_id=id, name="molecule.delete", text="&delete", 
icon=paths.icon_16x16.remove, fn=user_functions.molecule.delete)
-
-        id = self.add_class(name="molmol", text="&molmol", 
icon=paths.icon_16x16.molmol)
-        self.add_uf(parent_id=id, name="molmol.clear_history", 
text="clear_&history", icon=None, fn=user_functions.molmol.clear_history)
-        self.add_uf(parent_id=id, name="molmol.command", text="&command", 
icon=None, fn=user_functions.molmol.command)
-        self.add_uf(parent_id=id, name="molmol.macro_apply", 
text="&macro_apply", icon=paths.icon_16x16.molmol, 
fn=user_functions.molmol.macro_apply)
-        self.add_uf(parent_id=id, name="molmol.macro_run", 
text="macro_&run", icon=paths.icon_16x16.open, 
fn=user_functions.molmol.macro_run)
-        self.add_uf(parent_id=id, name="molmol.macro_write", 
text="macro_&write", icon=paths.icon_16x16.save, 
fn=user_functions.molmol.macro_write)
-        self.add_uf(parent_id=id, name="molmol.ribbon", text="ri&bbon", 
icon=None, fn=user_functions.molmol.ribbon)
-        self.add_uf(parent_id=id, name="molmol.tensor_pdb", 
text="&tensor_pdb", icon=None, fn=user_functions.molmol.tensor_pdb)
-        self.add_uf(parent_id=id, name="molmol.view", text="&view", 
icon=None, fn=user_functions.molmol.view)
-
-        id = self.add_class(name="noe", text="&noe", icon=None)
-        self.add_uf(parent_id=id, name="noe.read_restraints", 
text="&read_restraints", icon=paths.icon_16x16.open, 
fn=user_functions.noe.read_restraints)
-        self.add_uf(parent_id=id, name="noe.spectrum_type", 
text="&spectrum_type", icon=None, fn=user_functions.noe.spectrum_type)
-
-        id = self.add_class(name="pipe", text="&pipe", 
icon=paths.icon_16x16.pipe)
-        self.add_uf(parent_id=id, name="pipe.copy", text="&copy", 
icon=paths.icon_16x16.copy, fn=user_functions.pipe.copy)
-        self.add_uf(parent_id=id, name="pipe.create", text="crea&te", 
icon=paths.icon_16x16.add, fn=user_functions.pipe.create)
-        self.add_uf(parent_id=id, name="pipe.delete", text="&delete", 
icon=paths.icon_16x16.remove, fn=user_functions.pipe.delete)
-        self.add_uf(parent_id=id, name="pipe.hybridise", text="&hybridise", 
icon=paths.icon_16x16.pipe_hybrid, fn=user_functions.pipe.hybridise)
-        self.add_uf(parent_id=id, name="pipe.switch", text="&switch", 
icon=paths.icon_16x16.pipe_switch, fn=user_functions.pipe.switch)
-
-        id = self.add_class(name="pymol", text="&pymol", 
icon=paths.icon_16x16.pymol)
-        self.add_uf(parent_id=id, name="pymol.clear_history", 
text="clear_&history", icon=None, fn=user_functions.pymol.clear_history)
-        self.add_uf(parent_id=id, name="pymol.command", text="&command", 
icon=None, fn=user_functions.pymol.command)
-        self.add_uf(parent_id=id, name="pymol.macro_apply", 
text="&macro_apply", icon=paths.icon_16x16.pymol, 
fn=user_functions.pymol.macro_apply)
-        self.add_uf(parent_id=id, name="pymol.macro_run", 
text="&macro_&run", icon=paths.icon_16x16.open, 
fn=user_functions.pymol.macro_run)
-        self.add_uf(parent_id=id, name="pymol.macro_write", 
text="macro_&write", icon=paths.icon_16x16.save, 
fn=user_functions.pymol.macro_write)
-        self.add_uf(parent_id=id, name="pymol.ribbon", text="ri&bbon", 
icon=None, fn=user_functions.pymol.ribbon)
-        self.add_uf(parent_id=id, name="pymol.tensor_pdb", 
text="&tensor_pdb", icon=None, fn=user_functions.pymol.tensor_pdb)
-        self.add_uf(parent_id=id, name="pymol.view", text="&view", 
icon=None, fn=user_functions.pymol.view)
-
-        id = self.add_class(name="relax_data", text="&relax_data", 
icon=paths.icon_16x16.relax_data)
-        self.add_uf(parent_id=id, name="relax_data.delete", text="&delete", 
icon=paths.icon_16x16.remove, fn=user_functions.relax_data.delete)
-        self.add_uf(parent_id=id, name="relax_data.read", text="&read", 
icon=paths.icon_16x16.open, fn=user_functions.relax_data.read)
-
-        id = self.add_class(name="relax_fit", text="relax_&fit", icon=None)
-        self.add_uf(parent_id=id, name="relax_fit.relax_time", 
text="&relax_time", icon=None, fn=user_functions.relax_fit.relax_time)
-        self.add_uf(parent_id=id, name="relax_fit.select_model", 
text="&select_model", icon=None, fn=user_functions.relax_fit.select_model)
-
-        id = self.add_class(name="residue", text="resid&ue", 
icon=paths.icon_16x16.residue)
-        self.add_uf(parent_id=id, name="residue.copy", text="&copy", 
icon=paths.icon_16x16.copy, fn=user_functions.residue.copy)
-        self.add_uf(parent_id=id, name="residue.create", text="crea&te", 
icon=paths.icon_16x16.add, fn=user_functions.residue.create)
-        self.add_uf(parent_id=id, name="residue.delete", text="&delete", 
icon=paths.icon_16x16.remove, fn=user_functions.residue.delete)
-
-        id = self.add_class(name="results", text="&results", 
icon=fetch_icon("relax.relax"))
-        self.add_uf(parent_id=id, name="results.display", text="&display", 
icon=None, fn=user_functions.results.display)
-        self.add_uf(parent_id=id, name="results.read", text="&read", 
icon=paths.icon_16x16.open, fn=user_functions.results.read)
-        self.add_uf(parent_id=id, name="results.write", text="&write", 
icon=paths.icon_16x16.save, fn=user_functions.results.write)
-
-        self.add_uf(parent_id=None, name="script", text="s&cript", 
icon=paths.icon_16x16.uf_script, fn=user_functions.script.run)
-
-        id = self.add_class(name="select", text="se&lect", icon=None)
-        self.add_uf(parent_id=id, name="select.all", text="&all", icon=None, 
fn=user_functions.select.all)
-        self.add_uf(parent_id=id, name="select.read", text="&read", 
icon=paths.icon_16x16.open, fn=user_functions.select.read)
-        self.add_uf(parent_id=id, name="select.reverse", text="re&verse", 
icon=None, fn=user_functions.select.reverse)
-        self.add_uf(parent_id=id, name="select.spin", text="&spin", 
icon=paths.icon_16x16.spin, fn=user_functions.select.spin)
-
-        id = self.add_class(name="sequence", text="se&quence", 
icon=paths.icon_16x16.sequence)
-        self.add_uf(parent_id=id, name="sequence.copy", text="&copy", 
icon=paths.icon_16x16.copy, fn=user_functions.sequence.copy)
-        self.add_uf(parent_id=id, name="sequence.read", text="&read", 
icon=paths.icon_16x16.open, fn=user_functions.sequence.read)
-        self.add_uf(parent_id=id, name="sequence.write", text="&write", 
icon=paths.icon_16x16.save, fn=user_functions.sequence.write)
-
-        id = self.add_class(name="spectrum", text="s&pectrum", icon=None)
-        self.add_uf(parent_id=id, name="spectrum.baseplane_rmsd", 
text="&baseplane_rmsd", icon=None, fn=user_functions.spectrum.baseplane_rmsd)
-        self.add_uf(parent_id=id, name="spectrum.delete", text="&delete", 
icon=paths.icon_16x16.remove, fn=user_functions.spectrum.delete)
-        self.add_uf(parent_id=id, name="spectrum.error_analysis", 
text="&error_analysis", icon=None, fn=user_functions.spectrum.error_analysis)
-        self.add_uf(parent_id=id, name="spectrum.integration_points", 
text="&integration_points", icon=None, 
fn=user_functions.spectrum.integration_points)
-        self.add_uf(parent_id=id, name="spectrum.read_intensities", 
text="&read_intensities", icon=paths.icon_16x16.open, 
fn=user_functions.spectrum.read_intensities)
-        self.add_uf(parent_id=id, name="spectrum.replicated", 
text="&replicated", icon=None, fn=user_functions.spectrum.replicated)
-
-        id = self.add_class(name="spin", text="&spin", 
icon=paths.icon_16x16.spin)
-        self.add_uf(parent_id=id, name="spin.copy", text="&copy", 
icon=paths.icon_16x16.copy, fn=user_functions.spin.copy)
-        self.add_uf(parent_id=id, name="spin.create", text="crea&te", 
icon=paths.icon_16x16.add, fn=user_functions.spin.create)
-        self.add_uf(parent_id=id, name="spin.create_pseudo", 
text="create_&pseudo", icon=paths.icon_16x16.add, 
fn=user_functions.spin.create_pseudo)
-        self.add_uf(parent_id=id, name="spin.delete", text="&delete", 
icon=paths.icon_16x16.remove, fn=user_functions.spin.delete)
-        self.add_uf(parent_id=id, name="spin.display", text="displa&y", 
icon=None, fn=user_functions.spin.display)
-        self.add_uf(parent_id=id, name="spin.element", text="&element", 
icon=None, fn=user_functions.spin.element)
-        self.add_uf(parent_id=id, name="spin.name", text="&name", icon=None, 
fn=user_functions.spin.name)
-        self.add_uf(parent_id=id, name="spin.number", text="num&ber", 
icon=None, fn=user_functions.spin.number)
-
-        id = self.add_class(name="structure", text="s&tructure", 
icon=paths.icon_16x16.structure)
-        self.add_uf(parent_id=id, name="structure.create_diff_tensor_pdb", 
text="&create_diff_tensor_pdb", icon=None, 
fn=user_functions.structure.create_diff_tensor_pdb)
-        self.add_uf(parent_id=id, name="structure.create_vector_dist", 
text="&create_vector_dist", icon=None, 
fn=user_functions.structure.create_vector_dist)
-        self.add_uf(parent_id=id, name="structure.delete", text="&delete", 
icon=paths.icon_16x16.remove, fn=user_functions.structure.delete)
-        self.add_uf(parent_id=id, name="structure.get_pos", text="&get_pos", 
icon=None, fn=user_functions.structure.get_pos)
-        self.add_uf(parent_id=id, name="structure.load_spins", 
text="&load_spins", icon=paths.icon_16x16.spin, 
fn=user_functions.structure.load_spins)
-        self.add_uf(parent_id=id, name="structure.read_pdb", 
text="&read_pdb", icon=paths.icon_16x16.open, 
fn=user_functions.structure.read_pdb)
-        self.add_uf(parent_id=id, name="structure.read_xyz", 
text="&read_xyz", icon=paths.icon_16x16.open, 
fn=user_functions.structure.read_xyz)
-        self.add_uf(parent_id=id, name="structure.vectors", text="&vectors", 
icon=None, fn=user_functions.structure.vectors)
-        self.add_uf(parent_id=id, name="structure.write_pdb", 
text="&write_pdb", icon=paths.icon_16x16.save, 
fn=user_functions.structure.write_pdb)
-
-        self.add_uf(parent_id=None, name="sys_info", text="sys_&info", 
icon=paths.icon_16x16.help_about, fn=user_functions.sys_info.sys_info)
-
-        id = self.add_class(name="value", text="&value", 
icon=paths.icon_16x16.value)
-        self.add_uf(parent_id=id, name="value.set", text="&set", 
icon=paths.icon_16x16.add, fn=user_functions.value.set)
-
-
-    def add_class(self, name=None, text=None, icon=None):
-        """Add the user function.
-
-        @keyword name:      The name of the user function, such as 
'residue.delete'.
-        @type name:         str
-        @keyword text:      The menu text string.
-        @type text:         str
-        @keyword icon:      The path to the icon image file for the menu 
entry.
-        @type icon:         str or None
-        @return:            The menu ID number.
-        @rtype:             long
-        """
-
-        # Generate a unique ID.
-        id = wx.NewId()
-
-        # Build the menu entry.
-        menu_item = build_menu_item(self.menu, id=id, text=text, icon=icon)
-
-        # The sub-menu.
-        sub_menu = wx.Menu()
-        menu_item.SetSubMenu(sub_menu)
-
-        # Append to the main menu item.
-        self.menu.AppendItem(menu_item)
-
-        # Return the ID.
-        return id
-
-
-    def add_uf(self, parent_id=None, name=None, text=None, icon=None, 
fn=None):
-        """Add the user function.
-
-        @keyword parent_id: The unique ID number of the parent menu entry.
-        @type parent_id:    long
-        @keyword name:      The name of the user function, such as 
'residue.delete'.
-        @type name:         str
-        @keyword text:      The menu text string.
-        @type text:         str
-        @keyword icon:      The path to the icon image file for the menu 
entry.
-        @type icon:         str or None
-        @keyword fn:        The user function to execute.
-        @type fn:           func
-        @return:            The menu ID number.
-        @rtype:             long
-        """
-
-        # Generate a unique ID.
-        id = wx.NewId()
-
-        # Store the data.
-        self.uf_names[id] = name
-        self.uf[id] = fn
-
-        # Build the menu entry.
-        if parent_id != None:
-            sub_menu = self.menu.FindItemById(parent_id).GetSubMenu()
-            item = build_menu_item(sub_menu, id=id, text=text, icon=icon)
-            sub_menu.AppendItem(item)
-
-        # No parent menu.
-        else:
-            item = build_menu_item(self.menu, id=id, text=text, icon=icon)
-            self.menu.AppendItem(item)
-
-        # Menu actions.
-        self.parent.Bind(wx.EVT_MENU, self.call, id=id)
-
-        # Return the ID.
-        return id
-
-
-    def call(self, event):
-        """Execute the given user function.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Get the ID.
-        id = event.GetId()
-
-        # Call the user function.
-        apply(self.uf[id])




Related Messages


Powered by MHonArc, Updated Sun May 13 12:40:02 2012