Author: bugman Date: Sat Dec 11 09:44:02 2010 New Revision: 11765 URL: http://svn.gna.org/viewcvs/relax?rev=11765&view=rev Log: Abstracted mol_name_element() into the base class method input_field(). 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=11765&r1=11764&r2=11765&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:44:02 2010 @@ -283,6 +283,36 @@ raise RelaxImplementError + def input_field(self, sizer, desc): + """Build the input field. + + @param sizer: The sizer to put the input field into. + @type sizer: wx.Sizer instance + @param desc: The text description. + @type desc: str + @return: The input field object. + @rtype: wx.TextCtrl instance + """ + + # Init. + field_sizer = wx.BoxSizer(wx.HORIZONTAL) + + # The molecule name. + 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) + + # The input field. + field = wx.TextCtrl(self, -1, '') + field.SetMinSize((50, self.input_size)) + field_sizer.Add(field, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, self.border) + + # Add to the main sizer. + sizer.Add(field_sizer) + + # Return the object. + return field + + def ok(self, event): """Accept the user function. 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=11765&r1=11764&r2=11765&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:44:02 2010 @@ -98,7 +98,7 @@ sizer.AddSpacer(self._spacing) # The molecule name input. - sizer.Add(self.mol_name_element(), 1, wx.ALIGN_TOP|wx.SHAPED, self.border) + self.mol_name = self.input_field(sizer, "The name of the molecule:") # Spacer. sizer.AddSpacer(self._spacing) @@ -118,29 +118,6 @@ # Set the name. self.interpreter.molecule.create(mol_name=mol_name, type=self.mol_type) - - - def mol_name_element(self): - """Build the molecule name element. - - @return: The box sizer. - @rtype: wx.Sizer instance - """ - - # Init. - sizer = wx.BoxSizer(wx.HORIZONTAL) - - # The molecule name. - text = wx.StaticText(self, -1, "The name of the molecule:", style=wx.ALIGN_RIGHT) - sizer.Add(text, 1, wx.LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, self.border) - - # The input field. - self.mol_name = wx.TextCtrl(self, -1, '') - self.mol_name.SetMinSize((50, self.input_size)) - sizer.Add(self.mol_name, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, self.border) - - # Return the sizer. - return sizer def mol_type_element(self):