[762] | 1 | #!/usr/bin/env python |
---|
| 2 | # -*- coding: utf-8 -*- |
---|
| 3 | #GSASII |
---|
| 4 | ########### SVN repository information ################### |
---|
| 5 | # $Date: 2020-03-11 21:43:45 +0000 (Wed, 11 Mar 2020) $ |
---|
| 6 | # $Author: toby $ |
---|
| 7 | # $Revision: 4361 $ |
---|
| 8 | # $URL: trunk/GSASII.py $ |
---|
| 9 | # $Id: GSASII.py 4361 2020-03-11 21:43:45Z toby $ |
---|
| 10 | ########### SVN repository information ################### |
---|
[903] | 11 | ''' |
---|
[3858] | 12 | *GSAS-II GUI* |
---|
[903] | 13 | ===================== |
---|
[762] | 14 | |
---|
[3858] | 15 | This is the script to start the GSAS-II graphical user interface (GUI). |
---|
[4148] | 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. |
---|
[903] | 24 | ''' |
---|
| 25 | |
---|
[4154] | 26 | import sys |
---|
[4349] | 27 | #import os |
---|
[3674] | 28 | import platform |
---|
[4148] | 29 | import wx |
---|
[762] | 30 | import GSASIIpath |
---|
[4148] | 31 | GSASIIpath.SetVersionNumber("$Revision: 4361 $") |
---|
[762] | 32 | |
---|
[3000] | 33 | __version__ = '1.0.0' |
---|
[762] | 34 | |
---|
[4154] | 35 | class G2App(wx.App): |
---|
| 36 | '''Used to create a wx python application for the GUI for Mac. |
---|
| 37 | Customized to implement drop of GPX files onto app. |
---|
| 38 | ''' |
---|
| 39 | startupMode = True |
---|
| 40 | def ClearStartup(self): |
---|
| 41 | '''Call this after app startup complete because a Drop event is posted |
---|
| 42 | when GSAS-II is initially started. |
---|
| 43 | ''' |
---|
| 44 | self.startupMode = False |
---|
| 45 | def MacOpenFiles(self, filenames): |
---|
| 46 | if self.startupMode: |
---|
| 47 | return |
---|
| 48 | for project in filenames: |
---|
| 49 | #print("Start GSAS-II with project file "+str(project)) |
---|
| 50 | GSASIIpath.MacStartGSASII(__file__,project) |
---|
| 51 | |
---|
[762] | 52 | if __name__ == '__main__': |
---|
[4154] | 53 | if sys.platform == "darwin": |
---|
| 54 | application = G2App(0) # create the GUI framework |
---|
| 55 | else: |
---|
| 56 | application = wx.App(0) # create the GUI framework |
---|
[3123] | 57 | try: |
---|
[3420] | 58 | GSASIIpath.SetBinaryPath(True) |
---|
[3123] | 59 | except: |
---|
| 60 | print('Unable to run with current setup, do you want to update to the') |
---|
| 61 | try: |
---|
[3674] | 62 | if '2' in platform.python_version_tuple()[0]: |
---|
| 63 | ans = raw_input("latest GSAS-II version? Update ([Yes]/no): ") |
---|
| 64 | else: |
---|
| 65 | ans = input("latest GSAS-II version? Update ([Yes]/no): ") |
---|
[3123] | 66 | except: |
---|
| 67 | ans = 'no' |
---|
| 68 | if ans.strip().lower() == "no": |
---|
| 69 | import sys |
---|
| 70 | print('Exiting') |
---|
| 71 | sys.exit() |
---|
| 72 | print('Updating...') |
---|
| 73 | GSASIIpath.svnUpdateProcess() |
---|
[3000] | 74 | import GSASIIdataGUI as G2gd |
---|
[4148] | 75 | G2gd.GSASIImain(application) # start the GUI |
---|
[4154] | 76 | if sys.platform == "darwin": |
---|
| 77 | wx.CallLater(100,application.ClearStartup) |
---|
[4361] | 78 | GSASIIpath.InvokeDebugOpts() |
---|
[4148] | 79 | application.MainLoop() |
---|