Skip to content

Commit 7783a04

Browse files
committed
fix LeBail bug #199; save splitter position, requiring fix to config save; fix ~/.GSAS-II use on Windows
1 parent 0842796 commit 7783a04

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

GSASII/GSASIIdataGUI.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,9 +2860,9 @@ def _init_ctrls(self, parent):
28602860
self.dataWindow = G2DataWindow(self.mainPanel)
28612861
dataSizer = wx.BoxSizer(wx.VERTICAL)
28622862
self.dataWindow.SetSizer(dataSizer)
2863-
self.mainPanel.SplitVertically(self.treePanel,
2864-
self.dataWindow.outer, 400)
2865-
self.Status.SetStatusWidths([200,-1]) # make these match?
2863+
sash = min(max(100,GSASIIpath.GetConfigValue('Split_Loc',250)),500)
2864+
self.mainPanel.SplitVertically(self.treePanel, self.dataWindow.outer, sash)
2865+
self.Status.SetStatusWidths([sash,-1]) # make these match?
28662866

28672867
G2G.wxID_GPXTREE = wx.NewId()
28682868
treeSizer = wx.BoxSizer(wx.VERTICAL)
@@ -4534,7 +4534,8 @@ def ExitMain(self, event):
45344534
'Main_Size':tuple(self.GetSize()),
45354535
'Plot_Pos':tuple(self.plotFrame.GetPosition()),
45364536
'Plot_Size':tuple(self.plotFrame.GetSize())}
4537-
GSASIIpath.SetConfigValue(FrameInfo)
4537+
GSASIIpath.AddConfigValue(FrameInfo)
4538+
GSASIIpath.AddConfigValue({'Split_Loc':self.mainPanel.GetSashPosition()})
45384539
config = G2G.GetConfigValsDocs()
45394540
G2G.SaveConfigVars(config)
45404541
except:

GSASII/GSASIIpath.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def GetConfigValue(key,default=None,getDefault=False):
6060
def SetConfigValue(parmdict):
6161
'''Set configuration variables. Note that parmdict is a dictionary
6262
from :func:`GSASIIctrlGUI.GetConfigValsDocs` where each element is a
63-
lists. The first item in list is the default value, the second is
63+
list. The first item in list is the default value, the second is
6464
the value to use for that configuration variable. Most of the
6565
information gathered in GetConfigValsDocs is no longer used.
6666
'''
@@ -76,6 +76,15 @@ def SetConfigValue(parmdict):
7676
if parmdict[var][0] == parmdict[var][1]: continue
7777
configDict[var] = parmdict[var][1]
7878

79+
def AddConfigValue(valsdict):
80+
'''Set configuration variables.
81+
82+
:param dict valsdict: a dictionary of values that are added
83+
directly to configDict.
84+
'''
85+
global configDict
86+
configDict.update(valsdict)
87+
7988
def GetConfigDefault(key):
8089
'''Return the default value for a config value
8190
@@ -2168,7 +2177,11 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
21682177
# allows this to be done in the background.
21692178
import requests
21702179
url='https://github.com/AdvancedPhotonSource/GSAS-II/tags'
2171-
releases = requests.get(url=url)
2180+
try:
2181+
releases = requests.get(url=url)
2182+
except:
2183+
print('background get tags failed')
2184+
sys.exit()
21722185
taglist = [tag.split('"')[0] for tag in releases.text.split('AdvancedPhotonSource/GSAS-II/releases/tag/')[1:]]
21732186
lastver = sorted([t for t in taglist if 'v' in t])[-1]
21742187
lastnum = sorted([t for t in taglist if 'v' not in t],key=int)[-1]

GSASII/GSASIIscriptable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def SetDebugMode(mode):
8282
This will provide some additional output that may help with
8383
tracking down problems in the code.
8484
'''
85-
GSASIIpath.SetConfigValue({'debug':bool(mode)})
85+
GSASIIpath.AddConfigValue({'debug':bool(mode)})
8686

8787
def installScriptingShortcut():
8888
'''Creates a file named G2script in the current Python site-packages directory.

GSASII/GSASIIstrMain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def RefineCore(Controls,Histograms,Phases,restraintDict,rigidbodyDict,parmDict,h
437437
if IfOK:
438438
if CheckLeBail(Phases): # only needed for LeBail extraction
439439
G2stMth.errRefine([],[Histograms,Phases,restraintDict,rigidbodyDict],
440-
parmDict,[],calcControls,pawleyLookup,dlg)
440+
parmDict,histDict1,[],calcControls,pawleyLookup,dlg)
441441
G2stMth.GetFobsSq(Histograms,Phases,parmDict,calcControls)
442442
if chisq0 is not None:
443443
Rvals['GOF0'] = np.sqrt(chisq0/(Histograms['Nobs']-len(varyList)))

GSASII/config_example.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@
145145
these widows. If position is outside screen then it will be repositioned to default.
146146
This is used internally by GSAS-II and would not normally be changed by a user.
147147
'''
148+
Split_Loc = 250
149+
'''Location of the splitter bar between the data tree and the data window.
150+
Can be dragged by user. Is saved automatically with the window size and position
151+
'''
148152

149153
Tick_length = 8.0
150154
'''Specifies the length of phase tick marks in pixels. Default is 8.'''

GSASII/pathHacking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def appendIfExists(searchpathlist,loc,subdir):
2424
binseapath = [os.path.abspath(sys.path[0])] # where Python is installed
2525
binseapath += [os.path.abspath(os.path.dirname(__file__))] # directory where this file is found
2626
binseapath += [os.path.dirname(binseapath[-1])] # parent of above directory
27-
binseapath += [os.path.expanduser('~/.GSASII')] # directory in user's home
27+
binseapath += [os.path.expanduser(os.path.join('~','.GSASII'))] # directory in user's home
2828
searched = []
2929
for loc in binseapath:
3030
if loc in searched: continue

0 commit comments

Comments
 (0)