Skip to content

Commit 5e328a6

Browse files
committed
Add preference option to reload rather that restart; switch SeparateHistPhaseTreeItem to reload
1 parent cc9f4b5 commit 5e328a6

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

GSASII/GSASIIctrlGUI.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6680,6 +6680,7 @@ def __init__(self,parent):
66806680
self.vars = GetConfigValsDocs()
66816681
self.G2frame = parent
66826682
self.restart = False
6683+
self.reload = False
66836684

66846685
label = wx.StaticText(
66856686
self, wx.ID_ANY,
@@ -6728,6 +6729,8 @@ def OnChange(self,event=None):
67286729
self.saveBtn.Enable(True)
67296730
if 'restart' in self.vars[var][3].lower():
67306731
self.restart = True
6732+
elif 'reload' in self.vars[var][3].lower():
6733+
self.reload = True
67316734
break
67326735
else:
67336736
self.saveBtn.Enable(False)

GSASII/GSASIIdataGUI.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,7 @@ def OnPreferences(self,event):
23352335
try:
23362336
dlg.ShowModal() == wx.ID_OK
23372337
restart = dlg.restart
2338+
reload = dlg.reload
23382339
finally:
23392340
dlg.Destroy()
23402341
# trigger a restart if the var description asks for that
@@ -2364,6 +2365,11 @@ def OnPreferences(self,event):
23642365
G2fil.openInNewTerm(project)
23652366
print ('exiting GSAS-II')
23662367
sys.exit()
2368+
if reload:
2369+
ans = self.OnFileSave(None)
2370+
if not ans: return
2371+
self.clearProject() # clear out data tree
2372+
self.StartProject()
23672373

23682374
def _Add_ImportMenu_smallangle(self,parent):
23692375
'''configure the Small Angle Data menus accord to the readers found in _init_Imports
@@ -4225,10 +4231,7 @@ def GetGPX():
42254231
GetGPX()
42264232
filename = self.GSASprojectfile
42274233
else:
4228-
try:
4229-
self.GSASprojectfile = os.path.splitext(filename)[0]+u'.gpx'
4230-
except:
4231-
self.GSASprojectfile = os.path.splitext(filename)[0]+'.gpx'
4234+
self.GSASprojectfile = os.path.splitext(filename)[0]+'.gpx'
42324235
self.dirname = os.path.split(filename)[0]
42334236

42344237
# if self.G2plotNB.plotList:
@@ -4356,21 +4359,25 @@ def OnFileClose(self, event):
43564359
self.OnFileSaveMenu(event)
43574360
if result != wx.ID_CANCEL:
43584361
self.GSASprojectfile = ''
4359-
self.GPXtree.SetItemText(self.root,'Project: ')
4360-
self.GPXtree.DeleteChildren(self.root)
4361-
self.dataWindow.ClearData()
4362-
if len(self.HKL):
4363-
self.HKL = np.array([])
4364-
self.Extinct = []
4365-
if self.G2plotNB.plotList:
4366-
self.G2plotNB.clear()
4367-
self.SetTitleByGPX()
4368-
self.EnableRefineCommand()
4369-
self.init_vars()
4370-
G2obj.IndexAllIds({},{}) # clear old index info
4362+
self.clearProject()
43714363
finally:
43724364
dlg.Destroy()
43734365

4366+
def clearProject(self):
4367+
'Initializes the data tree etc.'
4368+
self.GPXtree.SetItemText(self.root,'Project: ')
4369+
self.GPXtree.DeleteChildren(self.root)
4370+
self.dataWindow.ClearData()
4371+
if len(self.HKL):
4372+
self.HKL = np.array([])
4373+
self.Extinct = []
4374+
if self.G2plotNB.plotList:
4375+
self.G2plotNB.clear()
4376+
self.SetTitleByGPX()
4377+
self.EnableRefineCommand()
4378+
self.init_vars()
4379+
G2obj.IndexAllIds({},{}) # clear old index info
4380+
43744381
def OnFileSave(self, event):
43754382
'''Save the current project in response to the
43764383
File/Save Project menu button
@@ -8943,6 +8950,10 @@ def OnShowShift(event):
89438950
G2pdG.UpdateLimitsGrid(G2frame,data,datatype)
89448951
G2pwpl.PlotPatterns(G2frame,plotType=datatype,newPlot=True,fromTree=True)
89458952
elif G2frame.GPXtree.GetItemText(item) == 'Instrument Parameters':
8953+
# if GSASIIpath.GetConfigValue('debug'):
8954+
# from importlib import reload
8955+
# reload(G2pdG)
8956+
# print('reloading G2pwdGUI')
89468957
G2frame.PatternId = G2frame.GPXtree.GetItemParent(item)
89478958
data = G2frame.GPXtree.GetItemPyData(item)[0]
89488959
G2pdG.UpdateInstrumentGrid(G2frame,data)

GSASII/config_example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,9 @@
302302
'''When this is set to True, the parameters specific to each histogram
303303
and phase together (such as peak shapes & phase fractions)
304304
are shown as a 1st-level tree item rather than inside each Phase's
305-
Data tab. After changing this, GSAS-II needs to be restarted for the
306-
change to take effect. Default is False.
305+
Data tab. If this is changed, the current GSAS-II project will be saved
306+
and will be reloaded for the change to take effect.
307+
Default is False.
307308
'''
308309

309310
G2RefinementWindow = False

0 commit comments

Comments
 (0)