mailr11785 - in /branches/bieri_gui/gui_bieri: menu.py user_functions/__init__.py user_functions/base.py user_functions/spin.py


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

Header


Content

Posted by edward on December 13, 2010 - 17:24:
Author: bugman
Date: Mon Dec 13 17:24:59 2010
New Revision: 11785

URL: http://svn.gna.org/viewcvs/relax?rev=11785&view=rev
Log:
Created the spin.create and spin.delete user function windows and menus.


Added:
    branches/bieri_gui/gui_bieri/user_functions/spin.py
      - copied, changed from r11782, 
branches/bieri_gui/gui_bieri/user_functions/molecule.py
Modified:
    branches/bieri_gui/gui_bieri/menu.py
    branches/bieri_gui/gui_bieri/user_functions/__init__.py
    branches/bieri_gui/gui_bieri/user_functions/base.py

Modified: branches/bieri_gui/gui_bieri/menu.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/menu.py?rev=11785&r1=11784&r2=11785&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/menu.py (original)
+++ branches/bieri_gui/gui_bieri/menu.py Mon Dec 13 17:24:59 2010
@@ -199,7 +199,11 @@
                 [id_base + 101, "&create", paths.icon_16x16.add, 
self.gui.user_functions.pipes.create],
                 [id_base + 102, "&delete", paths.icon_16x16.cancel, 
self.gui.user_functions.pipes.delete]
             ]],
-            [id_base + 200, "&script",   paths.icon_16x16.uf_script, 
self.gui.user_functions.script.run, []]
+            [id_base + 200, "&script",   paths.icon_16x16.uf_script, 
self.gui.user_functions.script.run, []],
+            [id_base + 100, "&spin", paths.icon_16x16.spin, None, [
+                [id_base + 101, "&create", paths.icon_16x16.add, 
self.gui.user_functions.spin.add],
+                [id_base + 102, "&delete", paths.icon_16x16.cancel, 
self.gui.user_functions.spin.delete]
+            ]],
         ]
 
         # Build.

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=11785&r1=11784&r2=11785&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/__init__.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/__init__.py Mon Dec 13 
17:24:59 2010
@@ -30,13 +30,15 @@
 from molecule import Molecule
 from pipes import Pipes
 from script import Script
+from spin import Spin
 
 
 # The package __all__ list.
 __all__ = ['base',
            'molecule',
            'pipes',
-           'script']
+           'script',
+           'spin']
 
 
 class User_functions:
@@ -57,6 +59,7 @@
         self.molecule = Molecule(self.gui, self.interpreter)
         self.pipes = Pipes(self.gui, self.interpreter)
         self.script = Script(self.gui, self.interpreter)
+        self.spin = Spin(self.gui, self.interpreter)
 
 
     def destroy(self):
@@ -65,3 +68,4 @@
         # Send the commands onwards to the user function classes.
         self.molecule.destroy()
         self.pipes.destroy()
+        self.spin.destroy()

Modified: branches/bieri_gui/gui_bieri/user_functions/base.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/base.py?rev=11785&r1=11784&r2=11785&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/base.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/base.py Mon Dec 13 17:24:59 
2010
@@ -326,7 +326,7 @@
         sizer.AddStretchSpacer()
 
 
-    def combo_box(self, sizer, desc, choices):
+    def combo_box(self, sizer, desc, choices, evt_fn=None):
         """Build the combo box element for list selections.
 
         @param sizer:   The sizer to put the input field into.
@@ -335,6 +335,8 @@
         @type desc:     str
         @param choices: The list of choices.
         @type choices:  list of str
+        @param evt_fn:  The event handling function.
+        @type evt_fn:   func
         """
 
         # Init.
@@ -354,6 +356,10 @@
         # Add to the main sizer (followed by stretchable spacing).
         sizer.Add(sub_sizer)
         sizer.AddStretchSpacer()
+
+        # Bind events.
+        if evt_fn:
+            self.Bind(wx.EVT_COMBOBOX, evt_fn, combo)
 
         # Return the combo box element.
         return combo

Copied: branches/bieri_gui/gui_bieri/user_functions/spin.py (from r11782, 
branches/bieri_gui/gui_bieri/user_functions/molecule.py)
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/spin.py?p2=branches/bieri_gui/gui_bieri/user_functions/spin.py&p1=branches/bieri_gui/gui_bieri/user_functions/molecule.py&r1=11782&r2=11785&rev=11785&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/molecule.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/spin.py Mon Dec 13 17:24:59 
2010
@@ -21,13 +21,14 @@
 
###############################################################################
 
 # Module docstring.
-"""The molecule user function GUI elements."""
+"""The spin user function GUI elements."""
 
 # Python module imports.
+from string import split
 import wx
 
 # relax module imports.
-from generic_fns.mol_res_spin import ALLOWED_MOL_TYPES, molecule_loop
+from generic_fns.mol_res_spin import molecule_loop, residue_loop, spin_loop
 from generic_fns import pipes
 
 # GUI module imports.
@@ -36,7 +37,7 @@
 
 
 # The container class.
-class Molecule(UF_base):
+class Spin(UF_base):
     """The container class for holding all GUI elements."""
 
     def setup(self):
@@ -48,7 +49,7 @@
 
 
     def add(self, event):
-        """The molecule.add user function.
+        """The spin.add user function.
 
         @param event:   The wx event.
         @type event:    wx event
@@ -58,7 +59,7 @@
 
 
     def delete(self, event):
-        """The molecule.delete user function.
+        """The spin.delete user function.
 
         @param event:   The wx event.
         @type event:    wx event
@@ -76,77 +77,144 @@
 
 
 class Add_window(UF_window):
-    """The molecule.add() user function window."""
+    """The spin.add() user function window."""
 
     # Some class variables.
     size_x = 600
     size_y = 400
-    frame_title = 'Add a molecule'
-    image_path = WIZARD_IMAGE_PATH + 'molecule.png'
-    main_text = 'This dialog allows you to add new molecules to the relax 
data store.  The molecule will be added to the current data pipe.'
-    title = 'Addition of new molecules'
+    frame_title = 'Add a spin'
+    image_path = WIZARD_IMAGE_PATH + 'spin.png'
+    main_text = 'This dialog allows you to add new spins to the relax data 
store.  The spin will be added to the current data pipe.'
+    title = 'Addition of new spins'
+
+
+    def _update_residues(self, event):
+        """Update the residue combo box.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Clear the previous data.
+        self.res.Clear()
+
+        # Clear the text.
+        self.res.SetValue('')
+
+        # The list of residue names.
+        mol_id = '#' + str(self.mol.GetValue())
+        for res in residue_loop(mol_id):
+            self.res.Append("%s %s" % (res.num, res.name))
 
 
     def add_uf(self, sizer):
-        """Add the molecule specific GUI elements.
+        """Add the spin specific GUI elements.
 
         @param sizer:   A sizer object.
         @type sizer:    wx.Sizer instance
         """
 
-        # The molecule name input.
-        self.mol_name = self.input_field(sizer, "The name of the molecule:")
+        # Molecule and residue selections.
+        self.mol = self.combo_box(sizer, "The molecule:", [], 
self._update_residues)
+        self.res = self.combo_box(sizer, "The residue:", [])
+
+        # The spin name input.
+        self.spin_name = self.input_field(sizer, "The name of the spin:")
 
         # The type selection.
-        self.mol_type = self.combo_box(sizer, "The type of molecule:", [''] 
+ ALLOWED_MOL_TYPES)
+        self.spin_num = self.input_field(sizer, "The spin number:")
 
 
     def execute(self):
         """Execute the user function."""
 
-        # Get the name and type.
-        mol_name = str(self.mol_name.GetValue())
-        mol_type = str(self.mol_type.GetValue())
+        # Get the spin info.
+        mol_name = str(self.mol.GetValue())
+        if mol_name == '':
+            mol_name = None
+
+        # The residue info.
+        res = str(self.res.GetValue())
+        res_num, res_name = split(res)
+        if res_name == '':
+            res_name = None
+        if res_num == '':
+            res_num = None
+        else:
+            res_num = int(res_num)
+
+        # The spin number.
+        spin_num = str(self.spin_num.GetValue())
+        if spin_num == '':
+            spin_num = None
+        else:
+            spin_num = int(spin_num)
+
+        # The spin name.
+        spin_name = str(self.spin_name.GetValue())
+        if spin_num == '':
+            spin_num = None
 
         # Set the name.
-        self.interpreter.molecule.create(mol_name=mol_name, type=mol_type)
+        self.interpreter.spin.create(spin_name=spin_name, spin_num=spin_num, 
res_name=res_name, res_num=res_num, mol_name=mol_name)
+
+
+    def update(self, event):
+        """Update the UI.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Clear the previous data.
+        self.mol.Clear()
+        self.res.Clear()
+
+        # Clear the text.
+        self.mol.SetValue('')
+        self.res.SetValue('')
+
+        # The list of molecule names.
+        if pipes.cdp_name():
+            for mol in molecule_loop():
+                self.mol.Append(mol.name)
 
 
 
 class Delete_window(UF_window):
-    """The molecule.delete() user function window."""
+    """The spin.delete() user function window."""
 
     # Some class variables.
     size_x = 600
     size_y = 400
-    frame_title = 'Delete a molecule'
-    image_path = WIZARD_IMAGE_PATH + 'molecule.png'
-    main_text = 'This dialog allows you to delete molecules from the relax 
data store.  The molecule will be deleted from the current data pipe.'
-    title = 'Molecule deletion'
+    frame_title = 'Delete a spin'
+    image_path = WIZARD_IMAGE_PATH + 'spin.png'
+    main_text = 'This dialog allows you to delete spins from the relax data 
store.  The spin will be deleted from the current data pipe.'
+    title = 'Spin deletion'
 
 
     def add_uf(self, sizer):
-        """Add the molecule specific GUI elements.
+        """Add the spin specific GUI elements.
 
         @param sizer:   A sizer object.
         @type sizer:    wx.Sizer instance
         """
 
-        # The molecule selection.
-        self.mol_name = self.combo_box(sizer, "The molecule:", [])
+        # The spin selection.
+        self.spin_name = self.combo_box(sizer, "The spin:", [])
 
 
     def execute(self):
         """Execute the user function."""
 
         # Get the name.
-        mol_name = str(self.mol_name.GetValue())
-
-        # The molecule ID.
-        id = '#' + mol_name
-
-        # Delete the molecule.
-        self.interpreter.molecule.delete(mol_id=id)
+        spin_name = str(self.spin_name.GetValue())
+
+        # The spin ID.
+        id = '#' + spin_name
+
+        # Delete the spin.
+        self.interpreter.spin.delete(spin_id=id)
 
         # Update.
         self.update(None)
@@ -160,12 +228,12 @@
         """
 
         # Clear the previous data.
-        self.mol_name.Clear()
-
-        # Clear the molecule name.
-        self.mol_name.SetValue('')
-
-        # The list of molecule names.
+        self.spin_name.Clear()
+
+        # Clear the spin name.
+        self.spin_name.SetValue('')
+
+        # The list of spin names.
         if pipes.cdp_name():
-            for mol in molecule_loop():
-                self.mol_name.Append(mol.name)
+            for spin in spin_loop():
+                self.spin_name.Append(spin.name)




Related Messages


Powered by MHonArc, Updated Mon Dec 13 17:40:02 2010