Author: bugman Date: Thu Jun 9 13:32:22 2011 New Revision: 12921 URL: http://svn.gna.org/viewcvs/relax?rev=12921&view=rev Log: Created the add_text_control() base class method for standardising the text controls. Modified: 1.3/gui/analyses/base.py Modified: 1.3/gui/analyses/base.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/analyses/base.py?rev=12921&r1=12920&r2=12921&view=diff ============================================================================== --- 1.3/gui/analyses/base.py (original) +++ 1.3/gui/analyses/base.py Thu Jun 9 13:32:22 2011 @@ -72,6 +72,40 @@ box.Add(label) + def add_text_control(self, box, parent, text='', control=wx.TextCtrl, width=-1, height=-1, editable=True): + """Add a text control field to the box. + + @param box: The box element to pack the control into. + @type box: wx.BoxSizer instance + @param parent: The parent GUI element. + @type parent: wx object + @keyword text: The default text of the control. + @type text: str + @keyword control: The control class to use. + @type control: wx.TextCtrl derived class + @keyword width: The minimum width of the control. + @type width: int + @keyword height: The minimum height of the control. + @type height: int + @keyword editable: A flag specifying if the control is editable or not. + @type editable: bool + """ + + # The control. + field = control(self.parent, -1, text) + + # The font and control properties. + field.SetMinSize((width, height)) + field.SetFont(self.gui.font_normal) + field.SetEditable(editable) + + # Add the control to the box. + box.Add(field, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) + + # Return the text field. + return field + + def add_title(self, box, text): """Create and add the frame title.