Author: bugman Date: Wed May 2 21:08:06 2012 New Revision: 15883 URL: http://svn.gna.org/viewcvs/relax?rev=15883&view=rev Log: Created a new wizard element for inputting integers. This will be used for user function args which should be integers. This is based on the string element. The wizard page element_int() method creates the element from the wizard_elements.Integer class. Modified: 1.3/gui/wizard.py 1.3/gui/wizard_elements.py Modified: 1.3/gui/wizard.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/wizard.py?rev=15883&r1=15882&r2=15883&view=diff ============================================================================== --- 1.3/gui/wizard.py (original) +++ 1.3/gui/wizard.py Wed May 2 21:08:06 2012 @@ -41,7 +41,7 @@ from gui.misc import add_border, bool_to_gui, gui_to_int, gui_to_str, int_to_gui, open_file, protected_exec, str_to_gui from gui.message import Question from gui import paths -from gui.wizard_elements import String, String_list, String_list_of_lists +from gui.wizard_elements import Integer, String, String_list, String_list_of_lists class Wiz_page(wx.Panel): @@ -551,8 +551,34 @@ return combo + def element_int(self, key=None, sizer=None, desc=None, tooltip=None, divider=None, padding=0, spacer=None): + """Set up the integer element and store it. + + @keyword key: The dictionary key to store the element with. + @type key: str + @keyword sizer: The sizer to put the input field widget into. + @type sizer: wx.Sizer instance + @keyword desc: The text description. + @type desc: str + @keyword tooltip: The tooltip which appears on hovering over the text or input field. + @type tooltip: str + @keyword divider: The optional position of the divider. If None, the class variable _div_left will be used. + @type divider: None or int + @keyword padding: Spacing to the left and right of the widgets. + @type padding: int + @keyword spacer: The amount of spacing to add below the field in pixels. If None, a stretchable spacer will be used. + @type spacer: None or int + """ + + # Create the element. + element = Integer(name=key, parent=self, sizer=sizer, desc=desc, tooltip=tooltip, divider=divider, padding=padding, spacer=spacer) + + # Store it. + self._elements[key] = element + + def element_string(self, key=None, sizer=None, desc=None, tooltip=None, divider=None, padding=0, spacer=None): - """Set up the element and store it. + """Set up the string element and store it. @keyword key: The dictionary key to store the element with. @type key: str Modified: 1.3/gui/wizard_elements.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/wizard_elements.py?rev=15883&r1=15882&r2=15883&view=diff ============================================================================== --- 1.3/gui/wizard_elements.py (original) +++ 1.3/gui/wizard_elements.py Wed May 2 21:08:06 2012 @@ -34,7 +34,7 @@ # relax GUI module imports. from gui.fonts import font -from gui.misc import add_border, gui_to_list, gui_to_str, list_to_gui, str_to_gui +from gui.misc import add_border, gui_to_int, gui_to_list, gui_to_str, int_to_gui, list_to_gui, str_to_gui from gui import paths @@ -139,6 +139,16 @@ # Convert and set the value. self._field.SetValue(self.convert_to_gui(value)) + + +class Integer(Base_value): + """Wizard GUI element for the input of integers.""" + + def conversion_fns(self): + """Set up the conversion functions.""" + + self.convert_from_gui = gui_to_int + self.convert_to_gui = int_to_gui class List: