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 ################### |
---|
11 | ''' |
---|
12 | *GSAS-II GUI* |
---|
13 | ===================== |
---|
14 | |
---|
15 | This is the script to start the GSAS-II graphical user interface (GUI). |
---|
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. |
---|
24 | ''' |
---|
25 | |
---|
26 | import sys |
---|
27 | #import os |
---|
28 | import platform |
---|
29 | import wx |
---|
30 | import GSASIIpath |
---|
31 | GSASIIpath.SetVersionNumber("$Revision: 4361 $") |
---|
32 | |
---|
33 | __version__ = '1.0.0' |
---|
34 | |
---|
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 | |
---|
52 | if __name__ == '__main__': |
---|
53 | if sys.platform == "darwin": |
---|
54 | application = G2App(0) # create the GUI framework |
---|
55 | else: |
---|
56 | application = wx.App(0) # create the GUI framework |
---|
57 | try: |
---|
58 | GSASIIpath.SetBinaryPath(True) |
---|
59 | except: |
---|
60 | print('Unable to run with current setup, do you want to update to the') |
---|
61 | try: |
---|
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): ") |
---|
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() |
---|
74 | import GSASIIdataGUI as G2gd |
---|
75 | G2gd.GSASIImain(application) # start the GUI |
---|
76 | if sys.platform == "darwin": |
---|
77 | wx.CallLater(100,application.ClearStartup) |
---|
78 | GSASIIpath.InvokeDebugOpts() |
---|
79 | application.MainLoop() |
---|