@@ -5900,13 +5900,13 @@ def __init__(self,frame,includeTree=False,morehelpitems=[]):
59005900 helpobj = self .Append (wx .ID_ANY ,lbl ,'' )
59015901 frame .Bind (wx .EVT_MENU , self .OnHelpById , helpobj )
59025902 self .HelpById [helpobj .GetId ()] = indx
5903- # add help lookup(s) in gsasii.html
5903+ # add help lookup(s) in GSAS-II Help
59045904 self .AppendSeparator ()
59055905 if includeTree :
59065906 helpobj = self .Append (wx .ID_ANY ,'Help on GSAS-II' ,
5907- 'Access web page with information on GSAS-II' )
5907+ 'Access web pages with information on GSAS-II' )
59085908 frame .Bind (wx .EVT_MENU , self .OnHelpById , id = helpobj .GetId ())
5909- self .HelpById [helpobj .GetId ()] = 'Data tree '
5909+ self .HelpById [helpobj .GetId ()] = 'HelpIntro '
59105910 helpobj = self .Append (wx .ID_ANY ,'Help on current data tree item\t F1' ,
59115911 'Access web page on selected item in tree' )
59125912 frame .Bind (wx .EVT_MENU , self .OnHelpById , id = helpobj .GetId ())
@@ -5916,21 +5916,18 @@ def __init__(self,frame,includeTree=False,morehelpitems=[]):
59165916
59175917 def OnHelpById (self ,event ):
59185918 '''Called when Help on... is pressed in a menu. Brings up a web page
5919- for documentation. Uses the helpKey value from the dataWindow window
5920- unless a special help key value has been defined for this menu id in
5921- self.HelpById
5922-
5923- Note that self should now (2frame) be child of the main window (G2frame)
5919+ for documentation. Uses the G2frame.dataWindow.helpKey value to select
5920+ what help is shown, unless a special help key value has been defined
5921+ for the calling menu id (via a lookup in self.HelpById[], which is used
5922+ for Tutorials & Overall help).
5923+ Note that G2frame.dataWindow.helpKey SelectDataTreeItem and reflects
5924+ the data tree item that has been selected.
5925+
5926+ Note that self here should be a child of the main window (G2frame)
5927+ where self.frame is G2frame
59245928 '''
5925- if hasattr (self .frame ,'dataWindow' ): # Debug code: check this is called from menu in G2frame
5926- # should always be true in 2 Frame version
5927- dW = self .frame .dataWindow
5928- else :
5929- print ('help error: not called from standard menu?' )
5930- print (self )
5931- return
59325929 try :
5933- helpKey = dW .helpKey # look up help from helpKey in data window
5930+ helpKey = self . frame . dataWindow .helpKey # look up help from helpKey in data window
59345931 #if GSASIIpath.GetConfigValue('debug'): print 'DBG_dataWindow help: key=',helpKey
59355932 except AttributeError :
59365933 helpKey = ''
@@ -6035,7 +6032,7 @@ def copy2clip(event):
60356032class HelpButton (wx .Button ):
60366033 '''Create a help button that displays help information.
60376034 The text can be displayed in a modal message window or it can be
6038- a reference to a location in the gsasII.html (etc.) help web page , in which
6035+ a reference to a location in the gsasII help web pages , in which
60396036 case that page is opened in a web browser.
60406037
60416038 TODO: it might be nice if it were non-modal: e.g. it stays around until
@@ -6046,9 +6043,12 @@ class HelpButton(wx.Button):
60466043 :param str msg: the help text to be displayed. Indentation on
60476044 multiline help text is stripped (see :func:`StripIndents`). If wrap
60486045 is set as non-zero, all new lines are
6049- :param str helpIndex: location of the help information in the gsasII.html
6050- help file in the form of an anchor string. The URL will be
6051- constructed from: location + gsasII.html + "#" + helpIndex
6046+ :param str helpIndex: selection for the help information in the GSAS-II
6047+ help files, in the form of an anchor string. That anchor is looked
6048+ up to find the file name and the URL is constructed from:
6049+
6050+ <location> + <filename> + "#" + helpIndex
6051+
60526052 :param int wrap: if specified, the text displayed is reformatted by
60536053 wrapping it to fit in wrap pixels. Default is None which prevents
60546054 wrapping.
@@ -7626,22 +7626,31 @@ class G2LstCtrl(wx.ListCtrl):
76267626htmlPanel = None
76277627htmlFrame = None
76287628htmlFirstUse = True
7629- #helpLocDict = {} # to be implemented if we ever split gsasii.html over multiple files
7629+ helpLocDict = {}
7630+ 'This is an index to the HTML anchors defined in the GSAS-II help files'
76307631path2GSAS2 = os .path .dirname (os .path .realpath (__file__ )) # save location of this file
76317632def ShowHelp (helpType ,frame ,helpMode = None ):
76327633 '''Called to bring up a web page for documentation.'''
76337634 global htmlFirstUse ,htmlPanel ,htmlFrame
7635+ if not helpLocDict : # load the anchor index
7636+ indx = os .path .abspath (os .path .join (path2GSAS2 ,'help' ,'anchorIndex.txt' ))
7637+ print ('reading file' ,indx )
7638+ with open (indx ,'r' ) as indexfile :
7639+ for line in indexfile .readlines ():
7640+ fil ,anchors = line .split (':' )
7641+ for a in anchors .split (',' ):
7642+ #if a in helpLocDict: print(a,'repeated!')
7643+ helpLocDict [a .strip ()] = fil
76347644 # no defined link to use, create a default based on key
7635- if helpType .lower ().startswith ('pwdr' ):
7636- helplink = 'gsasII-pwdr.html#' + helpType .replace (')' ,'' ).replace ('(' ,'_' ).replace (' ' ,'_' )
7637- elif helpType .lower ().startswith ('phase' ):
7638- helplink = 'gsasII-phase.html#' + helpType .replace (')' ,'' ).replace ('(' ,'_' ).replace (' ' ,'_' )
7639- elif helpType .lower ().startswith ('hist/phase' ):
7640- helplink = 'gsasII-phase.html#Phase-Data'
7641- elif helpType :
7642- helplink = 'gsasII.html#' + helpType .replace (')' ,'' ).replace ('(' ,'_' ).replace (' ' ,'_' )
7643- else :
7644- helplink = 'gsasII.html'
7645+ helplink = 'index.html'
7646+ if helpType :
7647+ anchor = helpType .replace (')' ,'' ).replace ('(' ,'_' ).replace (' ' ,'_' )
7648+ if anchor not in helpLocDict :
7649+ print (f'Help lookup problem, anchor { anchor } not found'
7650+ '\n Please report this to [email protected] along with a' 7651+ '\n screen image showing where you tried to get help' )
7652+ else :
7653+ helplink = f'{ helpLocDict [anchor ]} #{ anchor } '
76457654 # determine if a web browser or the internal viewer should be used for help info
76467655 if helpMode :
76477656 pass
0 commit comments