4444#from . import GSASIIstrMain as G2stMn
4545from . import GSASIImiscGUI as G2IO
4646from .tutorialIndex import tutorialIndex
47- if sys .version_info [0 ] >= 3 :
48- unicode = str
49- basestring = str
5047
5148# Define a short names for convenience
5249DULL_YELLOW = (230 ,230 ,190 )
@@ -406,7 +403,7 @@ def __init__(self,parent,loc,key,nDig=None,notBlank=True,xmin=None,xmax=None,
406403 self .type = int
407404 elif 'float' in str (type (val )):
408405 self .type = float
409- elif isinstance (val ,str ) or isinstance ( val , unicode ) :
406+ elif isinstance (val ,str ):
410407 self .type = str
411408 elif val is None :
412409 raise Exception ("ValidatedTxtCtrl error: value of " + str (key )+
@@ -469,7 +466,7 @@ def SetValue(self,val,warn=True):
469466 # for debugging flag calls. Set warn to False for calls that are not in callbacks
470467 # and thus are OK
471468 if GSASIIpath .GetConfigValue ('debug' ) and warn :
472- print ('ValidatedTxtCtrl.SetValue used in callback?' )
469+ print ('ValidatedTxtCtrl.SetValue() used in callback. Batter as ChangeValue() ?' )
473470 G2obj .HowDidIgetHere (True )
474471 if self .result is not None :
475472 self .result [self .key ] = val
@@ -2266,9 +2263,6 @@ def OnChoice(event):
22662263 copyopts = {'InTable' :False ,"startvalue" :None ,'currentsel' :None }
22672264 hst = G2frame .GPXtree .GetItemText (G2frame .PatternId )
22682265 histList = G2pdG .GetHistsLikeSelected (G2frame )
2269- if not histList :
2270- G2frame .ErrorDialog ('No match' ,'No histograms match ' + hst ,G2frame )
2271- return
22722266 dlg = wx .Dialog (G2frame ,wx .ID_ANY ,'Set a parameter value' ,
22732267 style = wx .DEFAULT_DIALOG_STYLE | wx .RESIZE_BORDER )
22742268 mainSizer = wx .BoxSizer (wx .VERTICAL )
@@ -2292,9 +2286,10 @@ def OnChoice(event):
22922286 mainSizer .Add (subSizer )
22932287
22942288 mainSizer .Add ((- 1 ,20 ))
2295- subSizer = wx .BoxSizer (wx .HORIZONTAL )
2296- subSizer .Add (G2CheckBox (dlg , 'Edit in table ' , copyopts , 'InTable' ))
2297- mainSizer .Add (subSizer )
2289+ if histList :
2290+ subSizer = wx .BoxSizer (wx .HORIZONTAL )
2291+ subSizer .Add (G2CheckBox (dlg , 'Edit in table ' , copyopts , 'InTable' ))
2292+ mainSizer .Add (subSizer )
22982293
22992294 btnsizer = wx .StdDialogButtonSizer ()
23002295 OKbtn = wx .Button (dlg , wx .ID_OK ,'Continue' )
@@ -2319,19 +2314,24 @@ def OnChoice(event):
23192314
23202315 copyList = []
23212316 lbl = copyopts ['currentsel' ]
2322- dlg = G2MultiChoiceDialog (G2frame ,'Copy parameter ' + lbl + ' from\n ' + hst ,
2323- 'Copy parameters' , histList )
2324- dlg .CenterOnParent ()
2325- try :
2326- if dlg .ShowModal () == wx .ID_OK :
2327- for i in dlg .GetSelections ():
2328- copyList .append (histList [i ])
2329- else :
2330- # reset the parameter since cancel was pressed
2331- array .update (saveArray )
2332- return
2333- finally :
2334- dlg .Destroy ()
2317+ ttl = 'Select histograms'
2318+ if copyopts ['InTable' ]:
2319+ msg = 'Select histograms to include in table'
2320+ else :
2321+ msg = f'Select hists to copy parameter { lbl } to.\n Fine w/no selections. Cancel aborts change.'
2322+ if histList :
2323+ dlg = G2MultiChoiceDialog (G2frame ,msg ,ttl , histList )
2324+ dlg .CenterOnParent ()
2325+ try :
2326+ if dlg .ShowModal () == wx .ID_OK :
2327+ for i in dlg .GetSelections ():
2328+ copyList .append (histList [i ])
2329+ else :
2330+ # reset the parameter since cancel was pressed
2331+ array .update (saveArray )
2332+ return
2333+ finally :
2334+ dlg .Destroy ()
23352335
23362336 prelbl = [hst ]
23372337 i = labelLst .index (lbl )
@@ -2604,7 +2604,7 @@ def ShowScrolledInfo(parent,txt,width=600,height=400,header='Warning info',
26042604 returns wx.ID_CANCEL
26052605 :returns: the wx Id for the selected button
26062606
2607- example ::
2607+ Example ::
26082608
26092609 res = ShowScrolledInfo(self.frame,msg,header='Please Note',buttonlist=[
26102610 ('Open', lambda event: event.GetEventObject().GetParent().EndModal(wx.ID_OK)),
@@ -3050,7 +3050,7 @@ class MultiDataDialog(wx.Dialog):
30503050 def __init__ (self ,parent ,title ,prompts ,values ,limits = [[0. ,1. ],],
30513051 testfxns = None ,formats = ['%.5g' ,],header = None ):
30523052 wx .Dialog .__init__ (self ,parent ,- 1 ,title ,
3053- pos = wx .DefaultPosition ,style = wx .DEFAULT_DIALOG_STYLE )
3053+ pos = wx .DefaultPosition ,style = wx .DEFAULT_DIALOG_STYLE | wx . RESIZE_BORDER )
30543054 self .panel = None
30553055 self .limits = limits
30563056 self .values = values
@@ -3230,6 +3230,7 @@ def OnValItem(event):
32303230 self .panel .SetSizer (mainSizer )
32313231 self .panel .Fit ()
32323232 self .Fit ()
3233+ self .CenterOnParent ()
32333234
32343235 def GetValues (self ):
32353236 return self .values
@@ -3690,6 +3691,14 @@ def ItemSelector(ChoiceList, ParentFrame=None,
36903691 :returns: the selection index or None or a selection list if multiple is true
36913692
36923693 Called by GSASIIdataGUI.OnReOrgSelSeq() Which is not fully implemented.
3694+
3695+ Example::
3696+
3697+ choices = ('NXazint1d 1D file','NXazint1d 2D file')
3698+ sel = G2G.ItemSelector(choices, ParentFrame=ParentFrame,
3699+ header='Select file section',
3700+ title='Select the section of the file to read')
3701+ if sel is None: return False
36933702 '''
36943703 if multiple :
36953704 if useCancel :
@@ -4758,11 +4767,7 @@ def __init__(self,G2frame,title,parmDict,varyList,fullVaryList,
47584767 self .frozenList = []
47594768 # make lists of variables of different types along with lists of parameter names, histogram #s, phase #s,...
47604769 self .parmNames = sorted (list (parmDict .keys ()))
4761- if '2' in platform .python_version_tuple ()[0 ]:
4762- basestr = basestring
4763- else :
4764- basestr = str
4765- splitNames = [item .split (':' ) for item in self .parmNames if len (item ) > 3 and not isinstance (self .parmDict [item ],basestr )]
4770+ splitNames = [item .split (':' ) for item in self .parmNames if len (item ) > 3 and not isinstance (self .parmDict [item ],str )]
47664771 globNames = [':' .join (item ) for item in splitNames if not item [0 ] and not item [1 ]]
47674772 if len (globNames ):
47684773 self .choiceDict ['Global' ] = G2obj .SortVariables (globNames )
@@ -5018,11 +5023,7 @@ def __init__(self, parent):
50185023 def SetContents (self ,parent ):
50195024 self .varList = []
50205025 for name in parent .choiceDict [parent .parmChoice ]:
5021- if '2' in platform .python_version_tuple ()[0 ]:
5022- basestr = basestring
5023- else :
5024- basestr = str
5025- if isinstance (parent .parmDict [name ],basestr ): continue
5026+ if isinstance (parent .parmDict [name ],str ): continue
50265027 if 'Refined' in parent .listSel and (name not in parent .fullVaryList
50275028 ) and (name not in parent .varyList ):
50285029 continue
@@ -5277,19 +5278,24 @@ def SetWildAfter(d,name,wname,mode):
52775278 # Callbacks to display info in table
52785279 def OnGetItemText (self , item , col ):
52795280 name = self .varList [item ]
5281+ atmParNam = None
5282+ if name .split (':' )[2 ].startswith ('dA' ):
5283+ atmParNam = name .replace (':dA' ,':A' )
52805284 if col == 0 :
52815285 return str (item )
52825286 elif col == 1 :
5287+ if atmParNam : return atmParNam
52835288 return name
52845289 elif col == 2 :
52855290 if name in self .parmWin .fullVaryList and name in self .parmWin .frozenList :
5286- return "F"
5291+ return "F"
52875292 elif name in self .parmWin .varyList :
52885293 return "R"
52895294 elif name in self .parmWin .fullVaryList :
52905295 return "C"
52915296 return ""
52925297 elif col == 3 :
5298+ if atmParNam : name = atmParNam
52935299 try :
52945300 value = G2fil .FormatSigFigs (self .parmWin .parmDict [name ])
52955301 except ValueError :
@@ -6227,7 +6233,7 @@ def tblLine(dlg,pixels=3):
62276233 dlg .Destroy ()
62286234
62296235################################################################################
6230- def viewWebPage (parent ,URL ,size = (750 ,450 ),newFrame = False ,HTML = '' ):
6236+ def viewWebPage (parent ,URL = '' ,size = (750 ,450 ),newFrame = False ,HTML = '' ):
62316237 '''Creates a child wx.Frame with an OS-managed web browser. The window
62326238 is modeless, so it can be left open without affecting GSAS-II operations,
62336239 but will be closed when GSAS-II is ended if a ``parent`` window is
@@ -6266,7 +6272,7 @@ def copyURL(event):
62666272 lastWebFrame .wv .SetPage (HTML ,'' )
62676273 else :
62686274 lastWebFrame .wv .LoadURL (URL )
6269- return
6275+ return dlg
62706276 except :
62716277 pass
62726278 dlg = wx .Frame (parent ,size = size )
@@ -6680,6 +6686,7 @@ def __init__(self,parent):
66806686 self .vars = GetConfigValsDocs ()
66816687 self .G2frame = parent
66826688 self .restart = False
6689+ self .reload = False
66836690
66846691 label = wx .StaticText (
66856692 self , wx .ID_ANY ,
@@ -6728,6 +6735,8 @@ def OnChange(self,event=None):
67286735 self .saveBtn .Enable (True )
67296736 if 'restart' in self .vars [var ][3 ].lower ():
67306737 self .restart = True
6738+ elif 'reload' in self .vars [var ][3 ].lower ():
6739+ self .reload = True
67316740 break
67326741 else :
67336742 self .saveBtn .Enable (False )
@@ -7691,6 +7700,15 @@ def ShowHelp(helpType,frame,helpMode=None):
76917700 helplink = os .path .join (path2GSAS2 ,'help' ,helplink )
76927701 pfx = "file://"
76937702 if sys .platform .lower ().startswith ('win' ):
7703+ # really don't understand what urlunsplit is doing, but this seems
7704+ # to prevent windows from encoding the # for the anchor
7705+ # (suggested by Google's AI!)
7706+ from urllib .parse import urlunsplit
7707+ f = helplink .split ('#' )[0 ]
7708+ a = ''
7709+ if '#' in helplink :
7710+ a = helplink .split ('#' )[1 ]
7711+ helplink = urlunsplit (['file' ,'' ,f ,'' ,a ])
76947712 pfx = ''
76957713 #if GSASIIpath.GetConfigValue('debug'): print 'DBG_Help link=',pfx+helplink
76967714 if htmlFirstUse :
@@ -8436,7 +8454,7 @@ def ChooseOrigin(G2frame,rd):
84368454 for atom in O2atoms :
84378455 for i in [0 ,1 ,2 ]:
84388456 atom [cx + i ] += T [i ]
8439- atom [cs :cs + 2 ] = G2spc .SytSym (atom [cx :cx + 3 ],SGData )[0 :2 ] # update symmetry & mult
8457+ atom [cs :cs + 2 ] = G2spc .SytSym (atom [cx :cx + 3 ],SGData )[0 :2 ] # update symmetry & mult
84408458 #get density & distances
84418459 DisAglData = {}
84428460 DisAglData ['SGData' ] = rd .Phase ['General' ]['SGData' ]
@@ -8563,7 +8581,7 @@ def OnSlider(event):
85638581 G2frame .Cmax = val
85648582 else :
85658583 G2frame .Cmin = val
8566- obj .txt .SetValue (int (Ymax * val ))
8584+ obj .txt .ChangeValue (int (Ymax * val ))
85678585 updatePlot ()
85688586 def OnNewVal (* args ,** kwargs ):
85698587 'respond when a value is placed in the min or max text box'
0 commit comments