mailr11766 - in /branches/bieri_gui/gui_bieri/user_functions: base.py molecule.py


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

Header


Content

Posted by edward on December 11, 2010 - 09:51:
Author: bugman
Date: Sat Dec 11 09:51:50 2010
New Revision: 11766

URL: http://svn.gna.org/viewcvs/relax?rev=11766&view=rev
Log:
Abstracted mol_type_element() into the base class method chooser().

This shifts all the GUI code into the base class.


Modified:
    branches/bieri_gui/gui_bieri/user_functions/base.py
    branches/bieri_gui/gui_bieri/user_functions/molecule.py

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=11766&r1=11765&r2=11766&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/base.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/base.py Sat Dec 11 09:51:50 
2010
@@ -277,6 +277,35 @@
         self.Close()
 
 
+    def chooser(self, sizer, desc, func, choices):
+        """Build the choice element.
+
+        @param sizer:   The sizer to put the input field into.
+        @type sizer:    wx.Sizer instance
+        @param desc:    The text description.
+        @type desc:     str
+        @param func:    The function to bind the event to
+        @type func:     func
+        @param choices: The list of choices.
+        @type choices:  list of str
+        """
+
+        # Init.
+        sub_sizer = wx.BoxSizer(wx.HORIZONTAL)
+
+        # The description.
+        text = wx.StaticText(self, -1, desc, style=wx.ALIGN_LEFT)
+        sub_sizer.Add(text, 1, wx.LEFT, self.border)
+
+        # The choice element.
+        type_choice = wx.Choice(self, -1, style=wx.ALIGN_LEFT, 
choices=choices)
+        sub_sizer.Add(type_choice, 1, wx.LEFT, self.border)
+        self.Bind(wx.EVT_CHOICE, func, type_choice)
+
+        # Add to the main sizer.
+        sizer.Add(sub_sizer)
+
+
     def execute(self):
         """Execute the user function (dummy method)."""
 
@@ -297,7 +326,7 @@
         # Init.
         field_sizer = wx.BoxSizer(wx.HORIZONTAL)
 
-        # The molecule name.
+        # The description.
         text = wx.StaticText(self, -1, desc, style=wx.ALIGN_RIGHT)
         field_sizer.Add(text, 1, 
wx.LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, self.border)
 

Modified: branches/bieri_gui/gui_bieri/user_functions/molecule.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/molecule.py?rev=11766&r1=11765&r2=11766&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/molecule.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/molecule.py Sat Dec 11 
09:51:50 2010
@@ -104,7 +104,7 @@
         sizer.AddSpacer(self._spacing)
 
         # The type selection.
-        sizer.Add(self.mol_type_element(), 1, wx.ALIGN_TOP, self.border)
+        self.chooser(sizer, "The type of molecule:", self._evt_mol_type, 
[''] + ALLOWED_MOL_TYPES)
 
         # Spacer.
         sizer.AddSpacer(self._spacing)
@@ -118,26 +118,3 @@
 
         # Set the name.
         self.interpreter.molecule.create(mol_name=mol_name, 
type=self.mol_type)
-
-
-    def mol_type_element(self):
-        """Build the molecule type element.
-
-        @return:    The box sizer.
-        @rtype:     wx.Sizer instance
-        """
-
-        # Init.
-        sizer = wx.BoxSizer(wx.HORIZONTAL)
-
-        # The molecule typ.
-        text = wx.StaticText(self, -1, "The type of molecule:", 
style=wx.ALIGN_LEFT)
-        sizer.Add(text, 1, wx.LEFT, self.border)
-
-        # The input field.
-        type_choice = wx.Choice(self, -1, style=wx.ALIGN_LEFT, choices=[''] 
+ ALLOWED_MOL_TYPES)
-        sizer.Add(type_choice, 1, wx.LEFT, self.border)
-        self.Bind(wx.EVT_CHOICE, self._evt_mol_type, type_choice)
-
-        # Return the sizer.
-        return sizer




Related Messages


Powered by MHonArc, Updated Sat Dec 11 10:00:02 2010