Changeset 4604


Ignore:
Timestamp:
Oct 17, 2020 5:49:37 PM (12 months ago)
Author:
toby
Message:

add help to Orientation reference controls; improve helpbutton formatting

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r4603 r4604  
    30183018                    Indx[refSel.GetId()] = i
    30193019                    refAtmSizer.Add(refSel,0,WACV)
     3020                    refHelpInfo = '''
     3021The Orientation reference control is used to tranform
     3022the Cartesian
     3023axes for rigid bodies with three atoms, A, B and C.
     3024The vector from A to B defines the x-axis and the z axis is placed
     3025in the plane defined by A to B and A to C.
     3026'''
     3027                hlp = G2G.HelpButton(VectorRBDisplay,refHelpInfo,wrap=400)
     3028                refAtmSizer.Add(hlp,0,wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL,2)
    30203029            return refAtmSizer
    30213030                       
     
    33723381                RefObjs.append(refObj)
    33733382                if 'molCent' not in rbData: rbData['molCent'] = False           #patch
    3374                 molcent = wx.Button(ResidueRBDisplay,label=' Use RB center?')
     3383                molcent = wx.Button(ResidueRBDisplay,label=' Center RB?')
    33753384                molcent.Bind(wx.EVT_BUTTON,OnMolCent)
    33763385                Indx[molcent.GetId()] = resGrid
    33773386                refAtmSizer.Add(molcent,0,WACV)
     3387                refHelpInfo = '''
     3388* The "Orientation Reference" control is used to tranform
     3389the Cartesian
     3390axes for rigid bodies with three atoms, A, B and C.
     3391The vector from A to B defines the x-axis and the z axis is placed
     3392in the plane defined by A to B and A to C.
     3393
     3394%%* The "Center RB?" button will redefine the origin of the
     3395rigid body to the midpoint of all atoms in the body (not mass weighted)
     3396'''
     3397                hlp = G2G.HelpButton(ResidueRBDisplay,refHelpInfo,wrap=400)
     3398                refAtmSizer.Add(hlp,0,wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL,2)
    33783399           
    33793400            mainSizer = wx.BoxSizer(wx.VERTICAL)
  • trunk/GSASIIctrlGUI.py

    r4594 r4604  
    51665166
    51675167    :param parent: the panel/frame where the button will be placed
    5168     :param str msg: the help text to be displayed
     5168    :param str msg: the help text to be displayed. Indentation on
     5169       multiline help text is stripped (see :func:`StripIndents`). If wrap
     5170       is set as non-zero, all new lines are
    51695171    :param str helpIndex: location of the help information in the gsasII.html
    51705172      help file in the form of an anchor string. The URL will be
    51715173      constructed from: location + gsasII.html + "#" + helpIndex
     5174    :param int wrap: if specified, the text displayed is reformatted by
     5175      wrapping it to fit in wrap pixels. Default is None which prevents
     5176      wrapping.
    51725177    '''
    5173     def __init__(self,parent,msg='',helpIndex=''):
     5178    def __init__(self,parent,msg='',helpIndex='',wrap=None):
    51745179        if sys.platform == "darwin":
    51755180            wx.Button.__init__(self,parent,wx.ID_HELP)
     
    51775182            wx.Button.__init__(self,parent,wx.ID_ANY,'?',style=wx.BU_EXACTFIT)
    51785183        self.Bind(wx.EVT_BUTTON,self._onPress)
    5179         self.msg=StripIndents(msg)
     5184        if wrap:
     5185            self.msg=StripIndents(msg,True)
     5186        else:
     5187            self.msg=StripIndents(msg)
    51805188        self.parent = parent
    51815189        self.helpIndex = helpIndex
     5190        self.wrap = wrap
    51825191    def _onClose(self,event):
    51835192        self.dlg.EndModal(wx.ID_CANCEL)
     
    51935202        mainSizer = wx.BoxSizer(wx.VERTICAL)
    51945203        txt = wx.StaticText(self.dlg,wx.ID_ANY,self.msg)
     5204        if self.wrap:
     5205            txt.Wrap(self.wrap)
    51955206        mainSizer.Add(txt,1,wx.ALL|wx.EXPAND,10)
    51965207        txt.SetBackgroundColour(wx.WHITE)
     
    52685279################################################################################
    52695280def StripIndents(msg,singleLine=False):
    5270     'Strip indentation from multiline strings'
     5281    '''Strip unintended indentation from multiline strings.
     5282    When singleLine is True, all newline are removed, but inserting "%%"
     5283    into the string will cause a blank line to be inserted at that point
     5284
     5285    :param str msg: a string containing one or more lines of text.
     5286      spaces or tabs following a newline are removed.
     5287    :returns: the string but reformatted
     5288    '''
    52715289    msg1 = msg.replace('\n ','\n')
    52725290    while msg != msg1:
    52735291        msg = msg1
    52745292        msg1 = msg.replace('\n ','\n')
    5275     msg = msg.replace('\n\t','\n')
     5293        msg1 = msg1.replace('  ',' ')
     5294    msg1 = msg.replace('\n\t','\n')
     5295    while msg != msg1:
     5296        msg = msg1
     5297        msg1 = msg.replace('\n\t','\n')
    52765298    if singleLine:
    5277         return msg.replace('\n',' ')
     5299        msg = msg.replace('\n',' ')
     5300        msg1 = msg.replace('  ',' ')
     5301        while msg != msg1:
     5302            msg = msg1
     5303            msg1 = msg1.replace('  ',' ')
     5304        msg = msg.replace('%%','\n\n')
    52785305    return msg
    52795306
Note: See TracChangeset for help on using the changeset viewer.