Author: bugman
Date: Mon May 7 18:18:56 2012
New Revision: 16067
URL: http://svn.gna.org/viewcvs/relax?rev=16067&view=rev
Log:
The user functions without a base class are now supported in the prompt,
script, and GUI modes.
This is for the auto-generated user functions not stored in a user function
class object.
Modified:
branches/uf_redesign/gui/menu.py
branches/uf_redesign/prompt/interpreter.py
Modified: branches/uf_redesign/gui/menu.py
URL:
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/menu.py?rev=16067&r1=16066&r2=16067&view=diff
==============================================================================
--- branches/uf_redesign/gui/menu.py (original)
+++ branches/uf_redesign/gui/menu.py Mon May 7 18:18:56 2012
@@ -25,6 +25,7 @@
"""Module for the main relax menu bar."""
# Python module imports.
+from re import search
from string import split
import wx
@@ -259,33 +260,42 @@
class_item = None
for name, data in uf_info.uf_loop():
# Split up the name.
- class_name, uf_name = split(name, '.')
+ if search('\.', name):
+ class_name, uf_name = split(name, '.')
+ else:
+ class_name = None
# Generate a sub menu.
- if class_name not in class_list:
- # Add the last sub menu.
- if class_item != None:
- menu.AppendItem(class_item)
-
- # Get the user function class data object.
- class_data = uf_info.get_class(class_name)
-
- # Create a unique ID.
- class_id = wx.NewId()
-
- # Create the menu entry.
- class_item = build_menu_item(menu, id=class_id,
text=class_data.menu_text, icon=fetch_icon(class_data.gui_icon, size='16x16'))
-
- # Initialise the sub menu.
- sub_menu = wx.Menu()
- class_item.SetSubMenu(sub_menu)
-
- # Add the class name to the list to block further sub menu
creation.
- class_list.append(class_name)
-
- # Create the user function menu entry.
- uf_id = wx.NewId()
- sub_menu.AppendItem(build_menu_item(sub_menu, id=uf_id,
text=data.menu_text, icon=fetch_icon(data.gui_icon, size='16x16')))
+ if class_name:
+ if class_name not in class_list:
+ # Add the last sub menu.
+ if class_item != None:
+ menu.AppendItem(class_item)
+
+ # Get the user function class data object.
+ class_data = uf_info.get_class(class_name)
+
+ # Create a unique ID.
+ class_id = wx.NewId()
+
+ # Create the menu entry.
+ class_item = build_menu_item(menu, id=class_id,
text=class_data.menu_text, icon=fetch_icon(class_data.gui_icon, size='16x16'))
+
+ # Initialise the sub menu.
+ sub_menu = wx.Menu()
+ class_item.SetSubMenu(sub_menu)
+
+ # Add the class name to the list to block further sub menu
creation.
+ class_list.append(class_name)
+
+ # Create the user function menu entry.
+ uf_id = wx.NewId()
+ sub_menu.AppendItem(build_menu_item(sub_menu, id=uf_id,
text=data.menu_text, icon=fetch_icon(data.gui_icon, size='16x16')))
+
+ # No sub menu.
+ else:
+ uf_id = wx.NewId()
+ menu.AppendItem(build_menu_item(menu, id=uf_id,
text=data.menu_text, icon=fetch_icon(data.gui_icon, size='16x16')))
# Bind the menu item.
self.gui.Bind(wx.EVT_MENU, store[name], id=uf_id)
Modified: branches/uf_redesign/prompt/interpreter.py
URL:
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/interpreter.py?rev=16067&r1=16066&r2=16067&view=diff
==============================================================================
--- branches/uf_redesign/prompt/interpreter.py (original)
+++ branches/uf_redesign/prompt/interpreter.py Mon May 7 18:18:56 2012
@@ -60,7 +60,6 @@
from fix import Fix
from gpl import GPL
from reset import Reset
-from minimisation import Minimisation
from model_selection import Modsel
from sys_info import Sys_info
from temperature import Temp
@@ -154,16 +153,23 @@
# Then generate the user functions.
for name, data in uf_info.uf_loop():
# Split up the name.
- class_name, uf_name = split(name, '.')
+ if search('\.', name):
+ class_name, uf_name = split(name, '.')
+ else:
+ class_name = None
# Generate a new container.
obj = Uf_object(name, title=data.title, kargs=data.kargs,
backend=data.backend, desc=data.desc, examples=data.prompt_examples,
additional=data.additional)
# Get the class object.
- class_obj = self._locals[class_name]
-
- # Add the object to the user function class.
- setattr(class_obj, uf_name, obj)
+ if class_name:
+ class_obj = self._locals[class_name]
+
+ # Add the object to the local namespace or user function class.
+ if class_name:
+ setattr(class_obj, uf_name, obj)
+ else:
+ self._locals[name] = obj
def _setup(self):
@@ -194,19 +200,15 @@
eliminate = Eliminate()
fix = Fix()
reset = Reset()
- minimisation = Minimisation()
modsel = Modsel()
opendx = OpenDX()
sys_info = Sys_info()
temp = Temp()
# Place the user functions in the local namespace.
- objects['calc'] = minimisation.calc
objects['eliminate'] = eliminate.eliminate
objects['fix'] = fix.fix
- objects['grid_search'] = minimisation.grid_search
objects['reset'] = reset.reset
- objects['minimise'] = minimisation.minimise
objects['model_selection'] = modsel.model_selection
objects['sys_info'] = sys_info.sys_info
objects['temperature'] = temp.set
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits