mailr16738 - in /branches/uf_redesign/gui/components: __init__.py software.py


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

Header


Content

Posted by edward on June 07, 2012 - 21:16:
Author: bugman
Date: Thu Jun  7 21:16:39 2012
New Revision: 16738

URL: http://svn.gna.org/viewcvs/relax?rev=16738&view=rev
Log:
Created a GUI element for listing and setting the software used in the 
analysis.

This will be used in the BMRB export window.


Added:
    branches/uf_redesign/gui/components/software.py
      - copied, changed from r16737, 
branches/uf_redesign/gui/components/molecule.py
Modified:
    branches/uf_redesign/gui/components/__init__.py

Modified: branches/uf_redesign/gui/components/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/components/__init__.py?rev=16738&r1=16737&r2=16738&view=diff
==============================================================================
--- branches/uf_redesign/gui/components/__init__.py (original)
+++ branches/uf_redesign/gui/components/__init__.py Thu Jun  7 21:16:39 2012
@@ -24,10 +24,13 @@
 """Package for the different GUI components for packing into sizer boxes."""
 
 
-__all__ = ['conversion',
+__all__ = ['citations',
+           'conversion',
            'grid',
            'menu',
            'molecule',
            'relax_data',
            'relax_data_meta',
+           'scripts',
+           'software',
            'spectrum']

Copied: branches/uf_redesign/gui/components/software.py (from r16737, 
branches/uf_redesign/gui/components/molecule.py)
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/components/software.py?p2=branches/uf_redesign/gui/components/software.py&p1=branches/uf_redesign/gui/components/molecule.py&r1=16737&r2=16738&rev=16738&view=diff
==============================================================================
--- branches/uf_redesign/gui/components/molecule.py (original)
+++ branches/uf_redesign/gui/components/software.py Thu Jun  7 21:16:39 2012
@@ -43,8 +43,8 @@
 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
 
 
-class Molecule:
-    """The GUI element for listing loaded molecules."""
+class Software:
+    """The GUI element for listing the software info."""
 
     # Some IDs for the menu entries.
     MENU_BMRB_THIOL_STATE = wx.NewId()
@@ -52,8 +52,8 @@
     MENU_MOLECULE_TYPE = wx.NewId()
 
 
-    def __init__(self, parent=None, box=None, id=None, stretch=False):
-        """Build the molecule list GUI element.
+    def __init__(self, parent=None, box=None, id=None, stretch=False, 
buttons=True):
+        """Build the software list GUI element.
 
         @keyword parent:    The parent GUI element that this is to be 
attached to (the panel object).
         @type parent:       wx object
@@ -65,6 +65,8 @@
         @type id:           str
         @keyword stretch:   A flag which if True will allow the static box 
to stretch with the window.
         @type stretch:      bool
+        @keyword buttons:   A flag which if True will display the buttons at 
the top.
+        @type buttons:      bool
         """
 
         # Store the arguments.
@@ -79,6 +81,7 @@
         # GUI variables.
         self.spacing = 5
         self.border = 5
+        self.height_buttons = 40
 
         # First create a panel.
         self.panel = wx.Panel(self.parent)
@@ -89,8 +92,7 @@
         self.panel.SetSizer(panel_sizer)
 
         # A static box to hold all the widgets, and its sizer.
-        self.data_box = wx.StaticBox(self.panel, -1)
-        self.set_box_label()
+        self.data_box = wx.StaticBox(self.panel, -1, "Software used")
         self.data_box.SetFont(font.subtitle)
         sub_sizer = wx.StaticBoxSizer(self.data_box, wx.VERTICAL)
 
@@ -107,76 +109,67 @@
         # Build the element.
         self.build_element()
 
+        # Add buttons.
+        if buttons:
+            self.add_buttons(box_centre)
+
         # Initialise observer name.
-        self.name = 'molecule: %s' % id
+        self.name = 'software: %s' % id
 
         # Register the element for updating when a user function completes.
         self.observer_register()
 
 
-    def action_bmrb_thiol_state(self, event):
-        """Launch the bmrb.thiol_state user function.
+    def action_bmrb_software(self, event):
+        """Launch the bmrb.software user function.
 
         @param event:   The wx event.
         @type event:    wx event
         """
 
-        # The current selection.
-        item = self.element.GetFirstSelected()
-
-        # The current state.
-        state = None
-        if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'thiol_state'):
-            state = cdp.exp_info.thiol_state
-
         # Launch the dialog.
-        if state == None:
-            uf_store['bmrb.thiol_state'](wx_parent=self.parent)
-        else:
-            uf_store['bmrb.thiol_state'](wx_parent=self.parent, state=state)
-
-
-    def action_molecule_name(self, event):
-        """Launch the molecule.name user function.
+        uf_store['bmrb.software'](wx_parent=self.parent)
+
+
+    def action_bmrb_software_select(self, event):
+        """Launch the bmrb.software_select user function.
 
         @param event:   The wx event.
         @type event:    wx event
         """
 
-        # The current selection.
-        item = self.element.GetFirstSelected()
-
-        # The spectrum ID.
-        id = gui_to_str(self.element.GetItemText(item))
-
         # Launch the dialog.
-        uf_store['molecule.name'](wx_parent=self.parent, mol_id=id)
-
-
-    def action_molecule_type(self, event):
-        """Launch the molecule.type user function.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # The current selection.
-        item = self.element.GetFirstSelected()
-
-        # The spectrum ID.
-        id = gui_to_str(self.element.GetItemText(item))
-
-        # The current type.
-        type = None
-        mol = return_molecule(id)
-        if hasattr(mol, 'type') and mol.type != None:
-            type = mol.type
-
-        # Launch the dialog.
-        if type == None:
-            uf_store['molecule.type'](wx_parent=self.parent, mol_id=id)
-        else:
-            uf_store['molecule.type'](wx_parent=self.parent, mol_id=id, 
type=type)
+        uf_store['bmrb.software_select'](wx_parent=self.parent)
+
+
+    def add_buttons(self, sizer):
+        """Add the buttons for peak list manipulation.
+
+        @param sizer:   The sizer element to pack the buttons into.
+        @type sizer:    wx.BoxSizer instance
+        """
+
+        # Button Sizer
+        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
+        sizer.Add(button_sizer, 0, wx.ALL|wx.EXPAND, 0)
+
+        # Add button.
+        self.button_add = 
wx.lib.buttons.ThemedGenBitmapTextButton(self.panel, -1, None, " Add")
+        
self.button_add.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-add-relax-blue',
 "22x22")))
+        self.button_add.SetFont(font.normal)
+        self.button_add.SetSize((80, self.height_buttons))
+        button_sizer.Add(self.button_add, 0, 0, 0)
+        self.parent.Bind(wx.EVT_BUTTON, self.action_bmrb_software, 
self.button_add)
+        self.button_add.SetToolTipString("Specify the software used in the 
analysis.")
+
+        # Select button.
+        self.button_add = 
wx.lib.buttons.ThemedGenBitmapTextButton(self.panel, -1, None, " Select")
+        
self.button_add.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.edit-select',
 "22x22")))
+        self.button_add.SetFont(font.normal)
+        self.button_add.SetSize((80, self.height_buttons))
+        button_sizer.Add(self.button_add, 0, 0, 0)
+        self.parent.Bind(wx.EVT_BUTTON, self.action_bmrb_software_select, 
self.button_add)
+        self.button_add.SetToolTipString("Select the software used in the 
analysis.")
 
 
     def build_element(self):
@@ -196,33 +189,16 @@
         # First freeze the element, so that the GUI element doesn't update 
until the end.
         self.element.Freeze()
 
-        # Update the label.
-        self.set_box_label()
-
         # Delete the previous data.
         self.element.DeleteAllItems()
 
         # Expand the number of rows to match the number of molecules, and 
add the data.
-        n = count_molecules()
-        i = 0
-        for mol, mol_id in molecule_loop(return_id=True):
-            # Set the index.
-            self.element.InsertStringItem(i, str_to_gui(mol_id))
-
-            # Set the molecule name.
-            if mol.name != None:
-                self.element.SetStringItem(i, 1, str_to_gui(mol.name))
-
-            # Set the molecule type.
-            if hasattr(mol, 'type'):
-                self.element.SetStringItem(i, 2, str_to_gui(mol.type))
-
-            # Set the thiol state.
-            if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 
'thiol_state'):
-                self.element.SetStringItem(i, 3, 
str_to_gui(cdp.exp_info.thiol_state))
-
-            # Increment the counter.
-            i += 1
+        n = 0
+        if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'software'):
+            n = len(cdp.exp_info.software)
+            for i in range(n):
+                # Set the software name.
+                self.element.InsertStringItem(i, 
str_to_gui(cdp.exp_info.software[i].name))
 
         # Size the columns.
         self.size_cols()
@@ -254,11 +230,8 @@
         # List of molecules.
         self.element = wx.ListCtrl(self.panel, -1, 
style=wx.BORDER_SUNKEN|wx.LC_REPORT)
 
-        # Initialise to 4 columns.
-        self.element.InsertColumn(0, str_to_gui("ID string"))
-        self.element.InsertColumn(1, str_to_gui("Name"))
-        self.element.InsertColumn(2, str_to_gui("Type"))
-        self.element.InsertColumn(3, str_to_gui("Thiol state"))
+        # Initialise to 1 columns.
+        self.element.InsertColumn(0, str_to_gui("Program name"))
 
         # Properties.
         self.element.SetFont(font.normal)
@@ -268,36 +241,9 @@
 
         # Bind some events.
         self.element.Bind(wx.EVT_SIZE, self.resize)
-        self.element.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.on_right_click)  
# For wxMSW!
-        self.element.Bind(wx.EVT_RIGHT_UP, self.on_right_click)   # For 
wxGTK!
 
         # Add list to sizer.
         sizer.Add(self.element, self.proportion, wx.ALL|wx.EXPAND, 0)
-
-
-    def is_complete(self):
-        """Determine if the data input is complete.
-
-        @return:    The answer to the question.
-        @rtype:     bool
-        """
-
-        # Loop over the molecules.
-        for mol in molecule_loop():
-            # No name.
-            if mol.name == None:
-                return False
-
-            # No molecule type.
-            if not hasattr(mol, 'type') or mol.type == None:
-                return False
-
-            # No thiol state.
-            if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 
'thiol_state'):
-                return False
-
-        # Data input is complete.
-        return True
 
 
     def observer_register(self, remove=False):
@@ -316,62 +262,18 @@
             status.observers.gui_uf.unregister(self.name)
 
 
-    def on_right_click(self, event):
-        """Pop up menu for the right click.
+    def resize(self, event):
+        """Catch the resize to allow the element to be resized.
 
         @param event:   The wx event.
         @type event:    wx event
         """
 
-        # Execution lock, so do nothing.
-        if status.exec_lock.locked():
-            return
-
-        # Initialise the menu.
-        menu = wx.Menu()
-
-        # Add some menu items for the spin user functions.
-        menu.AppendItem(build_menu_item(menu, id=self.MENU_MOLECULE_NAME, 
text="&Name the molecule", 
icon=fetch_icon(uf_info.get_uf('molecule.name').gui_icon)))
-        menu.AppendItem(build_menu_item(menu, id=self.MENU_MOLECULE_TYPE, 
text="Set the molecule &type", 
icon=fetch_icon(uf_info.get_uf('molecule.type').gui_icon)))
-        menu.AppendItem(build_menu_item(menu, id=self.MENU_BMRB_THIOL_STATE, 
text="Set the thiol &state", 
icon=fetch_icon(uf_info.get_uf('bmrb.thiol_state').gui_icon)))
-
-        # Bind clicks.
-        self.element.Bind(wx.EVT_MENU, self.action_molecule_name, 
id=self.MENU_MOLECULE_NAME)
-        self.element.Bind(wx.EVT_MENU, self.action_molecule_type, 
id=self.MENU_MOLECULE_TYPE)
-        self.element.Bind(wx.EVT_MENU, self.action_bmrb_thiol_state, 
id=self.MENU_BMRB_THIOL_STATE)
-
-        # Pop up the menu.
-        if status.show_gui:
-            self.element.PopupMenu(menu)
-            menu.Destroy()
-
-
-    def resize(self, event):
-        """Catch the resize to allow the element to be resized.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
         # Set the column sizes.
         self.size_cols()
 
         # Continue with the normal resizing.
         event.Skip()
-
-
-    def set_box_label(self):
-        """Set the label of the StaticBox."""
-
-        # Determine if the data input is complete.
-        label = "Molecule information "
-        if self.is_complete():
-            label += "(complete)"
-        else:
-            label += "(incomplete)"
-
-        # Set the label.
-        self.data_box.SetLabel(label)
 
 
     def size_cols(self):




Related Messages


Powered by MHonArc, Updated Thu Jun 07 21:40:02 2012