- Timestamp:
- Sep 13, 2019 5:06:45 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r3858 r4148 14 14 15 15 This is the script to start the GSAS-II graphical user interface (GUI). 16 This script imports GSASIIpath, does some minor initialization 17 and then launches :func:`GSASIIdataGUI.GSASIImain`, 18 which creates a wx.Application that in turns creates the GUI. 19 If the GSAS-II binaries are not installed or are incompatible with 20 the OS/Python packages, the user is asked if they should be updated 21 from the subversion site. 16 This script imports GSASIIpath, which does some minor initialization 17 and then (before any wxPython calls can be made) creates a wx.App application. 18 A this point :func:`GSASIIpath.SetBinaryPath` is called to establish 19 the directory where GSAS-II binaries are found. If the binaries 20 are not installed or are incompatible with the OS/Python packages, 21 the user is asked if they should be updated from the subversion site. 22 The wxPython app is then passed to :func:`GSASIIdataGUI.GSASIImain`, 23 which creates the GSAS-II GUI and finally the event loop is started. 22 24 ''' 23 25 24 26 import platform 27 import wx 25 28 import GSASIIpath 29 GSASIIpath.SetVersionNumber("$Revision$") 26 30 27 31 __version__ = '1.0.0' 28 32 29 33 if __name__ == '__main__': 34 application = wx.App(0) # create the GUI framework 30 35 try: 31 36 GSASIIpath.SetBinaryPath(True) … … 45 50 print('Updating...') 46 51 GSASIIpath.svnUpdateProcess() 47 GSASIIpath.SetVersionNumber("$Revision$")48 52 GSASIIpath.InvokeDebugOpts() 49 53 import GSASIIdataGUI as G2gd 50 G2gd.GSASIImain() # start the GUI 54 G2gd.GSASIImain(application) # start the GUI 55 application.MainLoop() -
trunk/GSASIIdataGUI.py
r4136 r4148 366 366 pass 367 367 print ("This is GSAS-II revision %s"%str(GSASIIpath.GetVersionNumber())+'\n') 368 368 369 def warnNumpyVersion(application): 370 dlg = wx.MessageDialog(application.main, 371 'version '+ np.__version__ + 372 ' of numpy produces .gpx files that are not compatible with older versions: please upgrade or downgrade numpy to avoid this version', 373 'numpy Warning',wx.OK) 374 try: 375 dlg.CenterOnParent() 376 dlg.ShowModal() 377 finally: 378 dlg.Destroy() 379 369 380 ############################################################################### 370 # Main application381 # GUI creation 371 382 ############################################################################### 372 def GSASIImain( ):373 '''Start up the GSAS-II application'''383 def GSASIImain(application): 384 '''Start up the GSAS-II GUI''' 374 385 ShowVersions() 375 386 GUIpatches() 376 #GSASIIpath.InvokeDebugOpts() 377 #application = GSASIImain() # don't redirect output, someday we 378 # may want to do this if we can 379 application = GSASIIGUI(0) 387 knownVersions = ['2.7','3.6','3.7','3.8'] 388 if platform.python_version()[:3] not in knownVersions: 389 dlg = wx.MessageDialog(None, 390 'GSAS-II requires Python 2.7.x or 3.6+\n Yours is '+sys.version.split()[0], 391 'Python version error', wx.OK) 392 try: 393 dlg.ShowModal() 394 finally: 395 dlg.Destroy() 396 sys.exit() 397 398 application.main = GSASII(None) # application.main is the main wx.Frame (G2frame in most places) 399 application.SetTopWindow(application.main) 400 # save the current package versions 401 application.main.PackageVersions = G2fil.get_python_versions([wx, mpl, np, sp, ogl]) 402 if np.__version__ == '1.16.0': 403 wx.CallLater(100,warnNumpyVersion,application) 380 404 if GSASIIpath.GetConfigValue('wxInspector'): 381 405 import wx.lib.inspection as wxeye 382 406 wxeye.InspectionTool().Show() 383 407 384 #application.main.OnRefine(None)385 408 try: 386 409 application.SetAppDisplayName('GSAS-II') … … 389 412 #application.GetTopWindow().SendSizeEvent() 390 413 application.GetTopWindow().Show(True) 391 application.MainLoop()392 393 class GSASIIGUI(wx.App):394 '''Defines a wxApp for GSAS-II395 396 Creates a wx frame (self.main) which contains the display of the397 data tree.398 '''399 def OnInit(self):400 '''Called automatically when the app is created.'''401 knownVersions = ['2.7','3.6','3.7','3.8']402 if platform.python_version()[:3] not in knownVersions:403 dlg = wx.MessageDialog(None,404 'GSAS-II requires Python 2.7.x or 3.6+\n Yours is '+sys.version.split()[0],405 'Python version error', wx.OK)406 try:407 dlg.ShowModal()408 finally:409 dlg.Destroy()410 sys.exit()411 self.main = GSASII(None)412 self.SetTopWindow(self.main)413 # save the current package versions414 self.main.PackageVersions = G2fil.get_python_versions([wx, mpl, np, sp, ogl])415 if np.__version__ == '1.16.0':416 wx.CallLater(100,self.warnNumpyVersion)417 return True418 def warnNumpyVersion(self):419 dlg = wx.MessageDialog(self.main,420 'version '+ np.__version__ +421 ' of numpy produces .gpx files that are not compatible with older versions: please upgrade or downgrade numpy to avoid this version',422 'numpy Warning',wx.OK)423 try:424 dlg.CenterOnParent()425 dlg.ShowModal()426 finally:427 dlg.Destroy()428 429 # def MacOpenFile(self, filename):430 # '''Called on Mac every time a file is dropped on the app when it is running,431 # treat this like a File/Open project menu action.432 # Should be ignored on other platforms433 # '''434 # # PATCH: Canopy 1.4 script main seems dropped on app; ignore .py files435 # print 'MacOpen',filename436 # if os.path.splitext(filename)[1] == '.py': return437 # # end PATCH438 # self.main.OnFileOpen(None,filename)439 # removed because this gets triggered when a file is on the command line in canopy 1.4 -- not likely used anyway440 414 441 415 ################################################################################
Note: See TracChangeset
for help on using the changeset viewer.