@@ -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 )
0 commit comments