Changeset 4604 for trunk/GSASIIctrlGUI.py
- Timestamp:
- Oct 17, 2020 5:49:37 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r4594 r4604 5166 5166 5167 5167 :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 5169 5171 :param str helpIndex: location of the help information in the gsasII.html 5170 5172 help file in the form of an anchor string. The URL will be 5171 5173 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. 5172 5177 ''' 5173 def __init__(self,parent,msg='',helpIndex='' ):5178 def __init__(self,parent,msg='',helpIndex='',wrap=None): 5174 5179 if sys.platform == "darwin": 5175 5180 wx.Button.__init__(self,parent,wx.ID_HELP) … … 5177 5182 wx.Button.__init__(self,parent,wx.ID_ANY,'?',style=wx.BU_EXACTFIT) 5178 5183 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) 5180 5188 self.parent = parent 5181 5189 self.helpIndex = helpIndex 5190 self.wrap = wrap 5182 5191 def _onClose(self,event): 5183 5192 self.dlg.EndModal(wx.ID_CANCEL) … … 5193 5202 mainSizer = wx.BoxSizer(wx.VERTICAL) 5194 5203 txt = wx.StaticText(self.dlg,wx.ID_ANY,self.msg) 5204 if self.wrap: 5205 txt.Wrap(self.wrap) 5195 5206 mainSizer.Add(txt,1,wx.ALL|wx.EXPAND,10) 5196 5207 txt.SetBackgroundColour(wx.WHITE) … … 5268 5279 ################################################################################ 5269 5280 def 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 ''' 5271 5289 msg1 = msg.replace('\n ','\n') 5272 5290 while msg != msg1: 5273 5291 msg = msg1 5274 5292 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') 5276 5298 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') 5278 5305 return msg 5279 5306
Note: See TracChangeset
for help on using the changeset viewer.